ajax call

JavaScript
$.ajax({
    url:'your url',
    type: 'POST',  // http method
    data: { myData: 'This is my data.' },  // data to submit
    success: function (data, status, xhr) { // after success your get data
        $('p').append('status: ' + status + ', data: ' + data);
    },
    error: function (jqXhr, textStatus, errorMessage) { // if any error come then 
            $('p').append('Error' + errorMessage);
    }
}); $.ajax({
        url: "Url",
        dataType: "json",
        type: "Post",
        async: true,
        data: {"Key":value,"Key2":value2},
        success: function (data) {
                
        },
        error: function (xhr, exception, thrownError) {
            var msg = "";
            if (xhr.status === 0) {
                msg = "Not connect.\n Verify Network.";
            } else if (xhr.status == 404) {
                msg = "Requested page not found. [404]";
            } else if (xhr.status == 500) {
                msg = "Internal Server Error [500].";
            } else if (exception === "parsererror") {
                msg = "Requested JSON parse failed.";
            } else if (exception === "timeout") {
                msg = "Time out error.";
            } else if (exception === "abort") {
                msg = "Ajax request aborted.";
            } else {
                msg = "Error:" + xhr.status + " " + xhr.responseText;
            }
            if (callbackError) {
                callbackError(msg);
            }
           
        }
    }); var id = empid;

$.ajax({
    type: "POST",
    url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
    data: "{empid: " + empid + "}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(result){
        alert(result.d);
        console.log(result);
    }
});
AJAX is allowing the Web page to retrieve small amounts of data from the
server without reloading the entire page. It is used for creating
fast and dynamic web pages.
There are several Wait methods I use to handle
AJAX calls. I add these pieces of code to my AJAX
testing code to handle it.
1. Explicit Waits
webdriver driver = new firefoxdriver();
driver.get("http://somedomain/url_that_delays_loading");
webelement mydynamicelement = (new webdriverwait(driver,10))
.until(expectedconditions.presenceofelementlocated(by.id("myd
ynamicelement")));
2. Implicit Waits
I also go for Implicit Waits, where I can decide on a
certain amount of time require WebDriver to poll the DOM for.  
 In this case your WebDriver will keep looking for an element(s),
 if it had been unavailable immediately. The default
time is set as 0, which can be easily adjusted as you may prefer.
In addition, this set wait time lasts as long as your browser is
open, so the time to search for any element on the page will be
the same.
webdriver driver = new firefoxdriver();
driver.manage().timeouts().implicitlywait(10,
timeunit.seconds);
driver.get("http://somedomain/url_that_delays_loading");
webelement mydynamicelement =
driver.findelement(by.id("mydynamicelement"));
Source

Also in JavaScript: