WHAT IS AJAX?

AJAX stands for Asynchronous Javascript and XML. It is not a programming language. It is a collection of technologies using which we can send to and receive data from the server without disturbing or reloading the existing page from the client side. It means we can update parts of a page using ajax without refreshing the page.

 

As the name says Asynchronous means not continuous. When asynchronous is set as true, the client program need not wait for the response from the server, even anything goes wrong in the request or transfer of the file. The client side program has the ability to find the problem and recover. Asynchronous processing avoids the delay thereby making the user interaction continuous with the web page.

 

Example:

$.ajax({
url: "testajax.php", type: "POST", async: true,
success: function(data) { // .....
}
});

 

When asynchronous is set as false, the client program has to wait for the response from the server. Synchronous javascript isn’t best option for outside unloading event handlers because there is a danger of request getting lost.

 

Example :

$.ajax({
url: "testajax.php", type: "POST", async: false,
success: function(data) { // .....
}
});