473,216 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Override asynchronous (XMLHttpRequest) activity?

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 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.)

If the user clicks on a button, it can take as long as 10 seconds for
the javascript that fires when the button is pushed to activate...
even if it's just creating an Alert()!

I want the XMLHttpRequests to load as quickly as possible UNLESS the
user does something, in which case I want to pause everything so the
user can feel like they're interacting well -- a button changes it's
css class to highlight a key letter or unhighlight it. (Of course it
works fine as is with Firefox and Opera, it's just the browser
everyone uses, Internet Explorer, that responds so sluggishly.)

- Stefan
Sep 30 '08 #1
5 3182
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);

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?

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.
- Conrad
Sep 30 '08 #2
On Sep 30, 9:29*pm, Roadworrier <roadworr...@gmail.comwrote:
(Of course it
works fine as is with Firefox and Opera, it's just the browser
everyone uses, Internet Explorer, that responds so sluggishly.)
There's no cure for IE...

--
Jorge.
Sep 30 '08 #3
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"...
Oct 1 '08 #4
Roadworrier wrote:
Thomas 'PointedEars' Lahn wrote:
>[...]
if (typeof window != "undefined"
&& /^(function|object|unknown)$/i.test(typeof window.setTimeout)
&& window.setTimeout)

I understand this example with the exception of the above line.
It is an attempt at determining whether there is a `window.setTimeout'
property that can be called, so as to avoid runtime errors since this DOM
feature is not universally available. First it is tested whether there is a
`window' identifier, to prevent ReferenceErrors when accessing its
properties; then the result of the typeof operation on its `setTimeout'
property is being matched against with a regular expression for results that
indicate methods

Doing such feature tests is usually recommended, especially for host-defined
properties; however, this feature has a rather long history, so you may not
need to test for it (it remains to be seen whether it can be considered safe
to use anyway).

Search this newsgroup and the Web for isMethod() and isMethodType(), which
are wrapper methods for this kind of feature test.
>HTH

It helps thanks.
You are welcome.
PointedEars
Oct 2 '08 #5
[Full test expression restored]

Roadworrier wrote:
Thomas 'PointedEars' Lahn wrote:
>[...]
if (typeof window != "undefined"
&& /^(function|object|unknown)$/i.test(typeof window.setTimeout)
&& window.setTimeout)

I understand this example with the exception of the above line.
The statement is a feature test, an attempt at determining whether there is
a `window.setTimeout' property that can be called, so as to avoid runtime
errors since this DOM feature is not universally available.

First it is tested whether there is a usable `window' identifier, to prevent
ReferenceErrors when trying to access properties. If that test is
successful, the result of the `typeof' operation on its `setTimeout'
property is being matched against by a Regular Expression for operation
results that are known to indicate methods. If that test is successful, it
is tested whether the value of the property can be type-converted to boolean
true (since e.g. `typeof null === "object"' but `!!null === false'). The
last two tests are designed to prevent TypeErrors when the property is
called (as a method). Only if all tests have been passed, the following
block statement is executed.

Doing such feature tests is usually recommended, especially for host-defined
properties. However, this particular feature has a rather long history, so
you may not need to test for it (it remains to be seen whether it can be
considered safe to use anyway).

Search this newsgroup and the Web for isMethod() and isMethodType(), which
are wrapper methods for this kind of feature test.
>HTH

It helps thanks.
You are welcome.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Oct 2 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Gaz | last post by:
In Internet Explorer 6 I'm having a problem with the httprequest object. I use it to call a webservice and display the result in the readystate event handler. This works the first time I call it...
0
by: ILAZAR | last post by:
Hey, I've created an Html file that uses the following script block to access the server via XMLHttpRequest: <script lang="jscript"> var objXMLHTTP = new ActiveXOject("MSxml2.XMLHttp");...
4
by: taskswap | last post by:
I have a legacy application written in C that I'm trying to convert to C#. It processes a very large amount of data from many clients (actually, upstream servers - this is a mux) simultaneously. ...
21
by: Joe Attardi | last post by:
Hey all! I was reading over at the IE Blog the other day http://http://blogs.msdn.com/ie/] and read some interesting, and encouraging news. According to Sunava Dutta, an IE Program Manager,...
8
by: Simon Gorski | last post by:
I have a large problem, and I believe there is not yet a way to solve this using IIS and ASP.NET. I hope someone has a solution which we couldn't find. The current situation When a user logs...
1
by: NorbertH | last post by:
Hi! After sending a request to a server via XMLHttpRequest and receiving a response, I assign an incoming XML from a server via var root = request.responseXML.documentElement; to the...
5
by: HugeBob | last post by:
Hi All, I've got a question about Asynchronous vs Synchronous mode with the XMLHttpRequest object. What are the ramifications of using one mode vs the other? If the script uses Asynchronous...
2
by: =?Utf-8?B?U3JpcmFtIE1hbGxhanlvc3VsYQ==?= | last post by:
Hi, I was going through the article (http://msdn.microsoft.com/msdnmag/issues/05/10/WickedCode/) regarding async programming in ASP.Net 2.0 but did not find much of an use with it. Actually...
4
by: Rex the Strange | last post by:
Seriously. I have a flash animation that I was trying to run during ajax calls - sort of eyecandy - but it would freeze whenever the ajax call was being made. Then I found out it wasn't just the...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.