JQuery - Submit Form To RESTful URL January 18, 2023 Post a Comment My mind has gone 100% blank on this so need some guidance please. Solution 1: Solution with jquery: $('#searchForm').on('submit', function(event){ $('[name=s]').prop('disabled', true) $(this).attr('action', 'http://example.com/rest/ful/url/' + $('[name=s]').val()); }); Copy https://jsfiddle.net/3y4efht0/1/ Solution 2: Use .submit event of jquery and fetch the input value and use window.location.href to achieve your requirement. Please check below snippet.Baca JugaDynamically Change Span Text Based On Selected Option JavascriptGoogle Map Direction Render Alternate Route How To Select Desired PathWhen To Use Function() , Function Or () => Function(callback) $("#searchForm").submit(function( event ) { var searchTerm = $("input[name='s']").val(); if($.trim(searchTerm)!=""){ var redirectURL = "http://example.com/rest/ful/url/"+$.trim(searchTerm)+"/"; console.log(redirectURL); window.location.href=redirectURL; }else{ alert("Please enter search term!"); } });Copy <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form action="/" id="searchForm"> <input type="text" name="s" placeholder="Search..."> <input type="submit" value="Search"> </form>Copy Solution 3: You don't need jquery to do that, but it can help, you have to listen for the submit event, prevent the default behaviour and redirect to the page you want : $('#searchForm').on('submit', function(e){ e.preventDefault(); document.location.href = 'http://example.com/rest/ful/url/'+$('#s').val()+'/' }) Copy Share You may like these postsCordova CORS Call Not WorkingEmpty Body Api Rest Express Node JsParse .then Method And Chaining | Syntax Eludes MeJavascript Error In REST WCF Url From Jquery Using Jsonp Post a Comment for "JQuery - Submit Form To RESTful URL"
Post a Comment for "JQuery - Submit Form To RESTful URL"