JQuery Ajax form submit Example

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.

Categorized as JQuery

By Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments