0

Possible Duplicate:
Is javascript guaranteed to be single-threaded?

Javascript works as single thread.But ajax works asynchronous, So what's the mechanism of it.It calls the setTimeouts and setInterval?

how dose the javascript code know that the ajax call has finished. By polling? it asks the server if the call is finished every 1ms?

Community
  • 1
  • 1
roast_soul
  • 3,554
  • 7
  • 36
  • 73
  • 2
    The browser interacts with the operating system and generates events when appropriate. – Pointy Oct 25 '12 at 14:54
  • 2
    I suggest you read the [accepted answer to this question](http://stackoverflow.com/questions/2734025/is-javascript-guaranteed-to-be-single-threaded). Short answer - JavaScript (in a browser) is not actually single-threaded. – RB. Oct 25 '12 at 14:56
  • http://www.garrickcheung.com/javascript/what-i-learned-about-multi-threading-in-javascript/ – Xinus Oct 25 '12 at 14:56
  • possible duplicate of [Who is the caller of onreadystatechange when javascript is single-threaded?](http://stackoverflow.com/q/11687352/1048572) – Bergi Oct 25 '12 at 14:59

0 Answers0