Connecting Tech Pros Worldwide Help | Site Map

Abort the AJAX Request (dojo)

  #1  
Old September 5th, 2008, 05:24 AM
Familiar Sight
 
Join Date: Aug 2007
Posts: 165
Hi All,

I am using dojo.xhrPost to send an ajax request.I would like to know if there is a way that when another javascipt event is executed before that request was finished, can I abort that request.
How can i abort the request? Thanks in Advance...
  #2  
Old September 5th, 2008, 08:04 AM
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9

re: Abort the AJAX Request (dojo)


why do you want to abort the ajax request?

nevertheless, you only need a second condition (besides request.status == 200) that the second javascript invokes.
  #3  
Old September 5th, 2008, 08:29 AM
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Posts: 102

re: Abort the AJAX Request (dojo)


I don't think you can abort ajax request. You can ignore handle the ajax response. for example:

Expand|Select|Wrap|Line Numbers
  1. var ajaxHandler = function( returnData )
  2. {
  3.     if ( flag == false )
  4.     {
  5.         //do something with the returnData
  6.     }
  7. }
  8.  
  9.  
  10. var otherEventHandler = function()
  11. {
  12.     flag = true;    //When another event is executed,set flag to true.
  13. }
  14.  
  15.  
  16. var flag = false;    //false when handle ajax response
  17. var ajax = new Ajax(...);    //initialize ajax object
  18. ajax.onreadystatechange = ajaxHandler;    //set ajax handler
  19. ajax.post(...);
  20.  
  21.  

hope it helps
  #4  
Old September 5th, 2008, 09:33 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: Abort the AJAX Request (dojo)


in case you have a reference to the requestobject then you may use its abort()-method ... have a look at it here

kind regards
  #5  
Old November 18th, 2008, 09:16 AM
Familiar Sight
 
Join Date: Aug 2007
Posts: 165

re: Abort the AJAX Request (dojo)


Hi,
I'm using dojo 1.1 in my application. How do i abort the ajax call in that?
please do needfull.
  #6  
Old November 18th, 2008, 09:49 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,521
Provided Answers: 12

re: Abort the AJAX Request (dojo)


Merged threads. Please do not double post your questions (even after a few months). Thanks.
  #7  
Old December 8th, 2008, 05:23 AM
Familiar Sight
 
Join Date: Aug 2007
Posts: 165

re: Abort the AJAX Request (dojo)


ISSUE IN ABORTING XHRPOST

We are using Dojo 1.1 to display data in grid format.

When the display button is clicked grid will be displayed and ajax calls( dojo xhrpost) will be initiated to fetch data. AJAX calls will update the session with fetched data. AJAX calls will be initiated until all the data is fetched.( Complete data set cannot be fetched at a stretch, as the data set is large. Hence we use AJAX calls to update the session)

If the display button is clicked again, the ongoing AJAX cals should be aborted and new AJAX calls should be triggered for the new serach criteria.

We are unable to abort the ongoing AJAX calls. The previous AJAX calls and the new AJAX calls are updating the data in session leading to incorrect data.

Please provide us some suggestion

Thanks
  #8  
Old December 8th, 2008, 02:03 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,521
Provided Answers: 12

re: Abort the AJAX Request (dojo)


Check post #4 by gits. If that doesn't help, check the API reference on the dojo website.
  #9  
Old December 9th, 2008, 09:49 AM
Familiar Sight
 
Join Date: Aug 2007
Posts: 165

re: Abort the AJAX Request (dojo)


How can we get the reference of XMLHTTPRequest in DOJO
  #10  
Old December 9th, 2008, 09:56 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,521
Provided Answers: 12

re: Abort the AJAX Request (dojo)


This link might help. Use the cancel() method. If that doesn't work, you can use the abort() method on the args object passed to the xhrPost function.
  #11  
Old December 9th, 2008, 10:01 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: Abort the AJAX Request (dojo)


here is another link that might be of help.
Reply