How To Get Post Variables In Jquery September 16, 2024 Post a Comment Possible Duplicate: how to get GET and POST variables with JQuery? I have the following HTML: {% csrf_token %} , function(){ $.ajax({ url: '', // script url to sendmethod: 'POST', // method of sendingdata: $('form').has(this).serialize(), // .serialize() make query string with form inputs name and valuedataType:'json', // expected data format returned from server, you may have something elsesuccess: function(response) { // response contains data returned from server } }); }); CopyIt would be better replace live() with .on() if you're using jQuery > 1.7 and it'd be better if possible. So you can write it$("#container").on('click', '#submit_financials', function(){ $.ajax({ url: '', // script url to sendmethod: 'POST', // method of sendingdata: $('form').has(this).serialize(), // .serialize() make query string with form inputs name and valuedataType:'json', // expected data format returned from server, you may have something elsesuccess: function(response) { // response contains data returned from server } }); }); CopyHere #container point to holder of #submit_financials that belong to DOM at page load.Solution 2: If all the values are in input elements on the form... $("#formId").serialize() CopySolution 3: You could serialize the form and send to the server page$.post("yourServerPage.php", $("form").serialize(),function(data){ //Do whatever with the result from ajax server page. }); CopySolution 4: How about creating several input values of type hidden<inputtype="hidden"id="sample_id" value="SOMETHING" /> Copygive them ids and acces the data inside using:Baca JugaMultilevel Hierarchical Edge BundlingDynamically Create Object Keys In Ie 11 (expected Identifier, String Or Number, Not A Comma Issue)'missing Semicolon' Warning In Eclipse For Javascript Code$('#sample_id').val() CopySolution 5: Unfortunately, POST variables are communicated in the request from the client to the server, but they are not automatically included in the response from the server back to the client. This is one of the things that sets them apart from GET variables.If your data isn't excessively long, you may want to switch to the GET method instead. You can then retrieve the variables using a function like one listed in this question: How can I get query string values in JavaScript? Alternatively, if you have access to the server-side code, you could include these variables in HTML returned; however this is another question entirely :) Share You may like these postsHow To Get Radio Button Value From First Page To Second Page Using Localstorage / Ajax JqueryWhy Request To Site Returns Error Access-Control-Allow-OriginAjax Post Not Working Without Alert MessageJavascript Link Loaded With Ajax Post a Comment for "How To Get Post Variables In Jquery"
Post a Comment for "How To Get Post Variables In Jquery"