How are AJAX requests made asynchronous if Javascript is not multi-threaded?
Is the implementation browser specific?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The browser execution model is based on the concept of an “event loop”. There’s only one thread servicing events (slight oversimplification). When an event happens, handlers are called in sequence.
Ajax is just a mechanism that causes certain events. Setting up an HTTP request is synchronous, but just setting it up. The browser responds to the network communications representing the return data from the server by triggering events when that happens.
Modern browsers are somewhat more complicated in that each window may have its own process (or some other system-level “thread” construct, to be general). Also, the new “web worker” feature allows separate thread-like compartments to run concurrently.