Tuesday 22 March 2011

Jquery making synchronous Ajax call

Difference between Synchronous and Asynchronous
  • Synchronous is where the script stops and waits for the server to send back a reply before continuing
  • Asynchronous is where the script allows the page to continue to be processed and will handle the reply if and when it arrives.
$.ajax({
type: "POST",
url: "url of the page",
processData: false,
success: function(msg) {alert("success")},
async:false 
});
If you see the last line, the attribute declaration async:false which is the key for the telling the Jquery client proxy to make asynchronous call or not. If it is true then asynchronous otherwise synchronous. By default it is asynchronous.

No comments:

Post a Comment