473,795 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3216
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(me thod, 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...@gm ail.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(me thod, 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|obje ct|unknown)$/i.test(typeof window.setTimeo ut)
&& window.setTimeo ut)

I understand this example with the exception of the above line.
It is an attempt at determining whether there is a `window.setTime out'
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|obje ct|unknown)$/i.test(typeof window.setTimeo ut)
&& window.setTimeo ut)

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.setTime out' 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 bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Oct 2 '08 #6

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

Similar topics

20
5056
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 but subsequently the readystate event handler function is never called, or the event itself is never fired. The same code works fine in Firefox. Changed it around a lot to no effect Can anyone help? I'm not supposed to create a new...
0
1379
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")­; objXMLHTTP.open("POST","http://MyServer/MySite/Page.asp",false); objXMLHTTP.setRequestHeader("C­ontent-Type","application/x-ww­w-form-urlencoded");
4
3822
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. I've read through what must be dozens of ways to do socket communication in C#, and it seems they all devolve into three basic options - Socket.Select, IOCP through a native interface, and Asynchronous callbacks. I'm fine using Asynchronous...
21
11759
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, starting in IE7 XMLHttpRequest will be a plain JavaScript object. It will still include the Microsoft.XMLHTTP ActiveX component for compatibility, but IMHO this is a very good shift for IE. What do you think?
8
1736
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 in to our website, we implement a single login for multiple services (let's call them services A-D). This means, that on the backend, while sampleuser logs in to our service with only one username and password, he is automatically logged in to...
1
1795
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 variable root which I process further with root.nodeType, root.nodeValue, etc...
5
15512
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 mode, it sounds as if a thread retrieves the data from the supplied URL and the JS function that called the open() and send() methods continues on. Where as using Synchronous mode the method that called open() and send() waits until the data from...
2
1462
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 my requirement is that once a user logs in I need to call a web service which will perform some activity but I am not bothered with the result of the web service. I have a process.aspx which is called after login and after implementing the code...
4
1525
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 flash, it was the entire page - could scroll, type, do jack. Asynchronous javascript? Yeah, right. (and before you suggest it, that isAscync parameter in the open function doesn't seem to do jack unless I'm not using a boolean correctly)
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.