Thanks for the reply Conrad.
On Sep 30, 7:35*pm, Conrad Lender <crlen...@yahoo.comwrote:
On 2008-09-30 21:29, Roadworrier wrote:
Hey, does anyone know how I can pause the processing of
XMLHttpRequests so that I can have the foreground interface respond to
user clicks?
I have no idea what you're doing in your scripts, but are you sure that
you're really sending *asynchronous* requests? Check if you have really
set the 'async' flag to true:
* (XHR object).open(method, uri, async);
Yes, I set the async parameter to true, and I can tell it's true
because I can watch the results return asynchronously from the server
with Firebug.
A locked-up user interface is usually the result of a synchronous
request - or, alternatively, bad application design:
I have 40 graphs drawing to the screen after getting 1000 points each
from a cgi contact with a remote server. (40 XMLHttpRequest calls, and
40,000 data points on which some statistics are calculated.)
Are you really sending *40* XHRs at the same time?
Why would you do such a thing?
And why would you be surprised by a lack of performance in this case?
Well, not exactly at the same time. On station with one trace is
showed on launch, one XHR. The user clicks to add a 2nd station, and
then a request for that new station is added. If the user clicks on a
different trace type then two more requests are sent, for a the 1st
station trace type 2, 2nd station trace type 2. If the user keeps
cheerfully clicking away, they'll eventually end up with up to 40
requests. Probably by the time they select everything a bunch of the
requests will be processed since it updates "realtime", but at least
half will still be remaining.
It wouldn't be a bad idea to rewrite my C cgi on the server end to be
able to handle more than one request at a time so that when there are
20 unprocessed requests they can be sent as a batch. It'll make the
feel a little less "realtime" but overall performance might be
perceived to improve.
As for your original question, no, you cannot "pause" XHRs. You can
cancel them (sort of), but if you design your application correctly, you
won't have to.
I was able to improve user feedback performance on IE by making it
slower; I set a 250ms setTimeout before processing any new XML
requests, and that allowed the user click highlight to get processed
much quicker. Still not as quick as I'd like, but maybe quick enough
to keep the scientists using this thing happy.
Any thoughts on redesign are welcome, if there are no solutions in
Javascript like "write this html (via JS) to screen at a higher
priority"...