How To Get POST Variables In JQuery October 13, 2022 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 send method: 'POST', // method of sending data: $('form').has(this).serialize(), // .serialize() make query string with form inputs name and value dataType:'json', // expected data format returned from server, you may have something else success: function(response) { // response contains data returned from server } }); }); Copy It 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 send method: 'POST', // method of sending data: $('form').has(this).serialize(), // .serialize() make query string with form inputs name and value dataType:'json', // expected data format returned from server, you may have something else success: function(response) { // response contains data returned from server } }); }); Copy Here #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() Copy Solution 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. }); Copy Solution 4: How about creating several input values of type hidden <input type="hidden" id="sample_id" value="SOMETHING" /> Copy give them ids and acces the data inside using:Baca JugaDjango Using Ajax With Forms, ViewsDynamically Populate Drop Down Menu With Selection From Previous Drop Down MenuRecord Voice With Recorder.js And Upload It To Python-flask Server, But Wav File Is Broken $('#sample_id').val() Copy Solution 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 postsDon't Reload Webpage After Flask Ajax RequestHow To Refresh A Table In Template Of DjangoDatatables Pagination Does Not ShowDynamically Added Row To Inline Formset Not Reflected In The Post Request In Views.py In Django Post a Comment for "How To Get POST Variables In JQuery"
Post a Comment for "How To Get POST Variables In JQuery"