How to post a form using jquery? [duplicate]
-
23-12-2020 - |
Question
Possible Duplicate:
submit a form using jquery
Hello friends
How can I submit a form using jquery. My form contain one file field also how can I post my form with out reloading the whole page. Any body can help me with some sample code?
Solution
$.ajax({
type: 'post',
url: 'servletToUSe',
data: {
"fieldValue": $('#fieldName').val()
},
success: function () {
//response handler
}
OTHER TIPS
As always nettuts provide a great tutorial for this - Submit A Form Without Page Refresh using jQuery
Probably the simplest way is to use jQuery Form plugin, which can be found on http://jquery.malsup.com/form/
Then in the simplest option you just need to put below mention code:
$(document).ready(function () {
$('#your_form_id').ajaxForm();
});
See the plugin's documentation for further details.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow