Hi,
Many of the folks are quite confused about the Synchronous and Asynchronous request in web application. May of us know that AJAX is an asynchronous request. But what does asynchronous mean?
Asynchronous request will not wait for response for an request. Let me explain with an example.
function Namecheck(){
var avilability = 1;
avilability = get_status("/user/check_name");
if avilability == 1
{
alert('avilable');
}
else{
alert('Not avilable');
}
}
In the above case 'get_status' will send an ajax request to "user/check_name" and it will not wait for the response for that request as it is an asynchronous, there by we always get the javascript alert as "avilable". So the function will execute without ant wait for response. This is how asynchronous request will work.
Synchronous request is the one which will wait until the complete response was received.
Note: to over come the response issue with AJAX we will use callback to trigger a function once the complete request was done with receiving a response.
Thank You,
Uma Mahesh
Many of the folks are quite confused about the Synchronous and Asynchronous request in web application. May of us know that AJAX is an asynchronous request. But what does asynchronous mean?
Asynchronous request will not wait for response for an request. Let me explain with an example.
function Namecheck(){
var avilability = 1;
avilability = get_status("/user/check_name");
if avilability == 1
{
alert('avilable');
}
else{
alert('Not avilable');
}
}
In the above case 'get_status' will send an ajax request to "user/check_name" and it will not wait for the response for that request as it is an asynchronous, there by we always get the javascript alert as "avilable". So the function will execute without ant wait for response. This is how asynchronous request will work.
Synchronous request is the one which will wait until the complete response was received.
Note: to over come the response issue with AJAX we will use callback to trigger a function once the complete request was done with receiving a response.
Thank You,
Uma Mahesh
No comments:
Post a Comment