Laurie Harper wrote:
Sounds like it'd be a lot easier to just fire the first request with a handler function that fires the next request, and so on, using onreadystatechange.

I would agree with that, *IF* the requests being sent are always the same and *IF* they are always in the same order. I suppose you could have branching logic in the handler if the variations aren't numerous, but a more general-purpose approach might be better, such as the suggestion I made about the queue and the timer firing calls off the stack.

Frank

L.

Frank W. Zammetti wrote:
No Wendy, you are correct in your explanation :) I see Ajax in Action is serving you well :)

I wouldn't expect it to be the best answer though because that parameter blocks *all* Javascript, not just further XMLHttpRequest's.

What you will probably want to do Michael is build up a queue on the client and write some code to ensure the order the handlers fire. This could be pretty tricky to say the least.

Take a look at the RequestSender tag in AjaxTags in Java Web Parts... AjaxTags builds up such a queue so that multiple requests can fire simultaneously without stepping on each other. I suspect you would be able to extend this to ensure firing order. Off the top of my head, I would think you would need to set up a timer, and when the responses come back, instead of processing them on the spot in the callback, instead set a flag in the call structure that says "yes, this request completed, but don't process it until the previous one completes"... fire the timer every half a second or something like that to examine all the call structures in the queue and fire them as appropriate.

Probably not a trivial exercise, but should be doable.

Frank


Wendy Smoak wrote:
On 2/1/06, Michael Jouravlev <[EMAIL PROTECTED]> wrote:

Hi, Ajax gurus, I have an OT question: how to ensure the proper order
of several XHRs? I found how to create several XHRs simultaneously,
but I have a requirement: to wait for the first request to return
before firing the second,

(Hardly an expert but...) the third parameter of
XMLHttpRequest.open(...) is a flag that says whether the request
should be asynchronous.  It's usually true.  Set it to false and I
think it will block until the response is received.  Frank will now
correct me if I'm wrong. :)

And lets move to the user list if this gets any further off topic, shall we?

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to