471,120 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,120 software developers and data experts.

single thread JavaScript and callbacks from XHR

If JavaScript is single threaded, what is happening if I have two ajax
calls executed around the same time. and they come back and hit two
different callbacks. Would the callback functions execute at the same
time together. Would one take precedence over the other?

Feb 16 '07 #1
3 1827
On Feb 16, 5:18 pm, "NeoAlchemy" <NeoAlch...@gmail.comwrote:
If JavaScript is single threaded, what is happening if I have
two ajax calls executed around the same time. and they come
back and hit two different callbacks. Would the callback
functions execute at the same time together. Would one take
precedence over the other?
(Assuming asynchronous request, which are the type that should be
used)The first response to get to the point of executing its -
onreadystatechange - handler would call its function first, and the
other at some subsequent point, after the first had finished.

Richard.

Feb 16 '07 #2
On Feb 16, 11:38 am, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:
On Feb 16, 5:18 pm, "NeoAlchemy" <NeoAlch...@gmail.comwrote:
If JavaScript is single threaded, what is happening if I have
two ajax calls executed around the same time. and they come
back and hit two different callbacks. Would the callback
functions execute at the same time together. Would one take
precedence over the other?

(Assuming asynchronous request, which are the type that should be
used)The first response to get to the point of executing its -
onreadystatechange - handler would call its function first, and the
other at some subsequent point, after the first had finished.

Richard.
Thank you that was what I was looking for.

Feb 17 '07 #3
On Feb 16, 11:38 am, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:
On Feb 16, 5:18 pm, "NeoAlchemy" <NeoAlch...@gmail.comwrote:
If JavaScript is single threaded, what is happening if I have
two ajax calls executed around the same time. and they come
back and hit two different callbacks. Would the callback
functions execute at the same time together. Would one take
precedence over the other?

(Assuming asynchronous request, which are the type that should be
used)The first response to get to the point of executing its -
onreadystatechange - handler would call its function first, and the
other at some subsequent point, after the first had finished.

Richard.
Thank you that was what I was looking for.

Feb 17 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Kiran | last post: by
6 posts views Thread by HolyShea | last post: by
13 posts views Thread by Samir Chouaieb | last post: by
19 posts views Thread by maya | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.