0

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

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.