Skip to content
Related Articles
Open in App
Not now

Related Articles

How to submit a form using ajax in jQuery ?

Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 10 Nov, 2021
Improve Article
Save Article
Like Article

jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript. Elaborating the terms, jQuery simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript development.

The $.ajax() function is used for ajax call using jQuery.


$.ajax({name:value, name:value, ... })

We can submit a form by ajax using submit button and by mentioning the values of the following parameters.

  • type: It is used to specify the type of request.
  • url: It is used to specify the URL to send the request to.
  • data: It is used to specify data to be sent to the server.




<!Doctype html>
    <title>JQuery AJAX Call</title>
    <!--Include JQuery Library -->
    <script src=
    // When DOM is loaded this 
    // function will get executed
    $(() => {
        // function will get executed 
        // on click of submit button
        $("#submitButton").click(function(ev) {
            var form = $("#formId");
            var url = form.attr('action');
                type: "POST",
                url: url,
                data: form.serialize(),
                success: function(data) {
                    // Ajax call completed successfully
                    alert("Form Submited Successfully");
                error: function(data) {
                    // Some error in ajax call
                    alert("some Error");
    <form id='formId' action=''> Name:
        <input type='text' 
        <br> Student ID:
        <input type='text' 
        <br> Contact No. :
        <input type='text' 
        <button type='submit' 


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!