Reputation: 4432
I have this call :
// some code;
myAjaxCall(
function abcd() {};
);
// more code
Can the more code and abcd executing in the same thread or different thread. I know it is asynchronous.
Upvotes: -1
Views: 363
Reputation: 700192
The AJAX request is asynchronous, but the JavaScript code is synchronous and single threaded.
The code following the AJAX call will complete before the abcd
function can run. The event that occurs when the response arrives can't be handled until the code exits and returns control to the browser.
Upvotes: 2
Reputation: 29831
Assuming myAjaxCall
is an ajax wrapper, and the first argument is the complete callback, the answer is "more code" will run before abcd function. But I'd need to see myAjaxCall function to know what is really going on.
Remember, the complete callback happens when ajax retruns. "more code" executes in the normal execution path.
Upvotes: 2