开发者

Javascript async and synchronous ajax ops

If I have a synchronous ajax call running, and an asynchronous开发者_JAVA技巧 call is made while that is happening (via setTimeout() ) will the second call stop/interupt/have any impact on the first call?


Javascript is single-threaded. As a result setTimeout calls can only fire while there is nothing else running. It will fire, once the synchronous ajax call completes and the function that made the ajax request yields control by returning.


Afaik, a synchronous call (aka blocking call) should block execution until the call is finished. From that I'd think the async call should start after the sync call has finished?

From the Mozilla Developer Center: You shouldn't use synchronous XMLHttpRequests because, due to the inherently asynchronous nature of networking, there are various ways memory and events can leak when using synchronous requests

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜