AJAX form submit with jQuery
Method 1
$.get('server.php?' + $('#theForm').serialize())
$.post('server.php', $('#theForm').serialize())
Method 2
With use of jQuery form plugin.
Send when the "Submit" button is pressed:
$("#theForm").ajaxForm({url: 'server.php', type: 'post'})
Send immediately:
$("#theForm").ajaxSubmit({url: 'server.php', type: 'post'})
Based on this SO answer.
Written by Dmitry Belaventsev
Related protips
1 Response
Method 3
$('form').on('submit', function() {
var $form = $(this);
$.post( $form.attr('action'), $form.serialize(), function(response) {
var response = $.parseJSON(response);
console.log("Response: ", response);
});
return false;
});
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Forms
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#