471,602 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

XMLhttp queuing?

Dear All,

Please excuse the following thickness, I am new to client scripting.

I have set up a page comprising of three DIVs, the content of which
gets changed by XMLHTTP requests (including the following code in a
function).

if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById(loc).innerHTML = xmlhttp.responseText;
}

My problem is when the page first loads. I had assumed that I could
just use onLoad to run a function that gets the data, but it gets
confused by the fact that it receives three queries in rapid
succession, before the server has had time to reply. How could I go
about queuing the requests so that they wait for one to load before the
next on triggers?

Everything works so well if I manually set up the pages - this is one
of the last hurdles I need to get through to have a promising looking
prototype. I am so impressed with how much more can be done with
JavaScript that when I last used it (a few years ago now) - no more
pages that strobe a rainbow of colours when you visit them!

I'd gratefully appreciate any advice that you (my obvious intellectual
superiors!) could provide on the issue.

Thank you kind Sirs (and Ladies),

Dan
(email not working - group reply appreciated)

Apr 2 '06 #1
1 1242
da*******@hotmail.com said on 03/04/2006 4:34 AM AEST:
Dear All,

Please excuse the following thickness, I am new to client scripting.

I have set up a page comprising of three DIVs, the content of which
gets changed by XMLHTTP requests (including the following code in a
function).

if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById(loc).innerHTML = xmlhttp.responseText;
}

My problem is when the page first loads. I had assumed that I could
just use onLoad to run a function that gets the data, but it gets
confused by the fact that it receives three queries in rapid
succession, before the server has had time to reply. How could I go
about queuing the requests so that they wait for one to load before the
next on triggers?


Firstly, what is 'it' referring to in '...it gets confused'? You need
to provide some error messages. A bit more code and snippet of HTML
might help too - just enough to show the error, not your entire application.

Secondly, are you creating the xmlhttp object as a global variable
(which seems pretty common). If so, you may be over-writing it with
subsequent calls.

You can queue the requests simply by having synchronous requests where
each request calls the next one - but that defeats the purpose of
HttpRequest to a large extent.

Consider using this stuff:

<URL:http://www.ajaxtoolbox.com/>
Look in the examples, there is one for a number of simultaneous
asynchronous requests.

--
Rob
Apr 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Just D. | last post: by
1 post views Thread by tiger | last post: by
1 post views Thread by Dave Pink | last post: by
9 posts views Thread by balakrishnan.dinesh | last post: by
13 posts views Thread by yawnmoth | last post: by
3 posts views Thread by Andrewh | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | 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.