suppose if there are multiple requests are fired with ajax and most of them are pending. After some time suppose if i want to abort all those requests then what should I do. Means how to maintain a pool of requests which are waiting since long and How to kill all those request. Do we have any thing like session.invalidate() and sessionListener kind.
firstly are you sure you can fire concurrent AJAX requests to the server? As far as I know, AJAX calls too happen in a sequential manner. If you fire a request before a previous one has completed, then the previous one automatically gets suppressed (something like if you click on two different links one after the other, then the second links call gets rendered).
You can run multiple XMLHttpRequest calls at the same time if you set the asynchronous flag to true on the call. You have to go to some effort to get the proper callback on the proper response. I got this off the net:
As far as cancelling requests, you cannot send a signal to the server to say "stop processing this request". You can decide to ignore the response. That logic would be very much dependent on what you're doing. [ September 05, 2007: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
firstly are you sure you can fire concurrent AJAX requests to the server?
Well, that's the whole purpose of Ajax in the first place.
Of course it's possible. When the request has been sent, the browser will call the onreadystatechange callback of the XHR object to provide some feedback about how the request is progressing. This is where you can decide whether to call abort() on the XHR object to kill the request.
Joined: Aug 26, 2001
you can iterate over the array and call abort() on each object and then delete the object altogether.
Joined: Jan 02, 2007
Thanks a lot. Could you please tell me what is XHRObject, we are using AjaxRequest class. Regards, Sree