Menu Close

Submitting a form with AJAX using jQuery

ajax-form

A short read to submit a form with AJAX (without reloading the page), you can use the ajaxForm/ajaxSubmit functions from Ajax form plugin or the jQuery serialize function.

Ajax Form:

$("#theForm").ajaxForm({url: 'server.php', type: 'post'}) 

 or alternatively:

$("#theForm").ajaxSubmit({url: 'server.php', type: 'post'}) 

ajaxForm will send when the submit button is pressed. ajaxSubmit sends immediately.

Serialize Method:

$.get('server.php?' + $('#theForm').serialize())

$.post('server.php', $('#theForm').serialize()) 
Posted in jQuery, Web Technologies

You can also read...