Abort the AJAX Request (dojo) 
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...
| 
September 5th, 2008, 08:04 AM
|  | 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.
| 
September 5th, 2008, 08:29 AM
|  | 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: -
var ajaxHandler = function( returnData )
-
{
-
if ( flag == false )
-
{
-
//do something with the returnData
-
}
-
}
-
-
-
var otherEventHandler = function()
-
{
-
flag = true; //When another event is executed,set flag to true.
-
}
-
-
-
var flag = false; //false when handle ajax response
-
var ajax = new Ajax(...); //initialize ajax object
-
ajax.onreadystatechange = ajaxHandler; //set ajax handler
-
ajax.post(...);
-
-
hope it helps
| 
September 5th, 2008, 09:33 AM
|  | 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
| 
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.
| 
November 18th, 2008, 09:49 AM
|  | 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.
| 
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
| 
December 8th, 2008, 02:03 PM
|  | 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.
| 
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
| 
December 9th, 2008, 09:56 AM
|  | 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.
| 
December 9th, 2008, 10:01 AM
|  | 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.
|  | | | | /bytes/about
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 225,689 network members.
|