What
is Synchronous & Asynchronous request ?
Ajax
request are two types –
- Synchronous
- Asynchronous
“Synchronous
means that at a single point of time from a webpage, we can send single request
and we will need to wait for the response before send the second request or to interact
with the webpage, while the request is processed on server.
“
i.e., Synchronous request stops the execution of rest of code and
an unresponsive user experience while request process by server. user can continue with the webpage after we get the
response of the
server against the request.
For
example, suppose on page load event of
webpage we are fetching the country List data to set in the Dropdown, For this,
if we made Synchronous ajax request then the rest of the code or elements
(images, forms, css etc.) will not load, until we get the response from the server.
Asynchronous means that the client will not need to wait for a response and
can continue to use the webpage while the request is being processed. i.e, we can send the second request before we get the response of
first request i.e., it doesn’t stop the execution of
remaining lines of code while processing the Ajax request .During
the complete round-trip the client is not halted.
No comments:
Post a Comment