Connecting Tech Pros Worldwide Forums | Help | Site Map

single thread JavaScript and callbacks from XHR

NeoAlchemy
Guest
 
Posts: n/a
#1: Feb 16 '07
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?

Richard Cornford
Guest
 
Posts: n/a
#2: Feb 16 '07

re: single thread JavaScript and callbacks from XHR


On Feb 16, 5:18 pm, "NeoAlchemy" <NeoAlch...@gmail.comwrote:
Quote:
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.

NeoAlchemy
Guest
 
Posts: n/a
#3: Feb 17 '07

re: single thread JavaScript and callbacks from XHR


On Feb 16, 11:38 am, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:
Quote:
On Feb 16, 5:18 pm, "NeoAlchemy" <NeoAlch...@gmail.comwrote:
>
Quote:
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.

NeoAlchemy
Guest
 
Posts: n/a
#4: Feb 17 '07

re: single thread JavaScript and callbacks from XHR


On Feb 16, 11:38 am, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:
Quote:
On Feb 16, 5:18 pm, "NeoAlchemy" <NeoAlch...@gmail.comwrote:
>
Quote:
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.

Closed Thread