Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old September 5th, 2008, 05:24 AM
Familiar Sight
 
Join Date: Aug 2007
Posts: 152
Default Abort the AJAX Request

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...
Reply
  #2  
Old September 5th, 2008, 08:04 AM
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 895
Default

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.
Reply
  #3  
Old September 5th, 2008, 08:29 AM
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Age: 22
Posts: 102
Default

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
Reply
  #4  
Old September 5th, 2008, 09:33 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Age: 36
Posts: 3,448
Default

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

kind regards
Reply
  #5  
Old November 18th, 2008, 09:16 AM
Familiar Sight
 
Join Date: Aug 2007
Posts: 152
Default ajaxRequest.abort()

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

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

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
Reply
  #8  
Old December 8th, 2008, 02:03 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,964
Default

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

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

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.
Reply
  #11  
Old December 9th, 2008, 10:01 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Age: 36
Posts: 3,448
Default

here is another link that might be of help.
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.