Let me explain First what the meaning of :
That is mean if we suppose that we have web page contains three requests..
when we send the first request to the server and after waiting the success response ( in case that no failure )… we will send the second request to the server and after waiting the success response ( in case that no failure ) … we will send the third request to … ( The same Scenario )..
Which will make the user nervous because no results will appears in the web page.
This problem solved by Asynchronous Callback Functions
Give your self time to think .. what the output of this code will be ?
if you think that the output will be :
A then B then C .. Unfortunately you are wrong !
The browser can access more than thread through Web APIs
– AJAX requests.
Let me explain what happens
During the run time .. your code execution Occurs in place called Stack..
if your code contains settimout , setinterval or any HTTPrequest .. the stack pass them to the web APIs to run it there.
After the web API finish .. will pass the result to place named Task queue .
And then the tasks in the queue will passed again to the stack through
Event Loop with one condition The Stack Must Be empty.
Now you can answer the question ? what the output of previous code will be ?
Yes you are right .. the output will be A then C then B.