Last updated on November 19, 2014
Sending Ajax requests to server with JQuery library is pretty easy. We just need to include JQuery in your page after that we can use JQuery’s ajax API methods in the page.
Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.
For better understanding ,i will create one HTML form and i will explain how to submit a HTML form asynchronously using jQuery AJAX API.
Here is my example form with 2 fields – name and email.
we generally use jQuery.ajax() method for sending ajax requests, But we can also use $.post() method for sending post requests and $.get() method for making get requests.
As usually i used $.ajax() method in the below example, and i used $.serializeArray() method to serialize form data instead of this you can also use $.serialize() method.Both methods works similar way.
always() will execute all ways (success and failure). we can use this for hiding ajax loader…etc .That’s it.