How to use ajax method in jquery?

AJAX stand for Asynchronous Javascript And XML. We can use ajax method in jquery whenever we want to work with web api. We can call web api using ajax URL and get or post the data.

Ex:

$.ajax({

    url:”http//http://localhost:2546/Student/Insert”,

    type: ‘POST’,  // http method

    data: { myData: ‘This is my data.’ },  // data to submit

    success: function (data, status, xhr) {

        $(‘p’).append(‘status: ‘ + status + ‘, data: ‘ + data);

    },

    error: function (jqXhr, textStatus, errorMessage) {

            $(‘p’).append(‘Error’ + errorMessage);

    }

})

Explaination:

url: It explains which api we are calling.

Type: the data is get or post