Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Killing Ajax requests

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Thanks in advance.

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.

Please help me..

Regards
Sree
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

I am not too sure whether you can do a check on open AJAX calls as well. Not atleast through JavaScript, since there's no multi-threading mechanism to do so, and the script execution halts at the point where you make an AJAX call. Maybe you can think of killing the request at the server side by multi-threading and returning a status through response if the call doesn't get served within a particular duration of time.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look into the abort() method

Eric
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

I am not too sure whether you can do a check on open AJAX calls as well. Not atleast through JavaScript, since there's no multi-threading mechanism to do so, and the script execution halts at the point where you make an AJAX call.

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.
 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Valentin,
Thanks a lot for your response.
I got some idea on how to do, however I have to kill the multiple requests of single user to be killed at a time.
I have some idea on the same could you please help me, Is it possible or not?
At javascript I am creating an array which will have AjaxRequest() class objects and I am able to print those objects in that array,however I don�t know how to fire a method to kill or destroy that object.

Regards,
Sree
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can iterate over the array and call abort() on each object and then delete the object altogether.

 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
Could you please tell me what is XHRObject, we are using AjaxRequest class.
Regards,
Sree
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Could you please tell me what is XHRObject



XMLHttpRequest
 
reply
    Bookmark Topic Watch Topic
  • New Topic