473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Abort the AJAX Request (dojo)

184 100+
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...
Sep 5 '08 #1
10 6072
Dormilich
8,658 Expert Mod 8TB
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.
Sep 5 '08 #2
Ferris
101 100+
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
Sep 5 '08 #3
gits
5,390 Expert Mod 4TB
in case you have a reference to the requestobject then you may use its abort()-method ... have a look at it here

kind regards
Sep 5 '08 #4
gaya3
184 100+
Hi,
I'm using dojo 1.1 in my application. How do i abort the ajax call in that?
please do needfull.
Nov 18 '08 #5
acoder
16,027 Expert Mod 8TB
Merged threads. Please do not double post your questions (even after a few months). Thanks.
Nov 18 '08 #6
gaya3
184 100+
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
Dec 8 '08 #7
acoder
16,027 Expert Mod 8TB
Check post #4 by gits. If that doesn't help, check the API reference on the dojo website.
Dec 8 '08 #8
gaya3
184 100+
How can we get the reference of XMLHTTPRequest in DOJO
Dec 9 '08 #9
acoder
16,027 Expert Mod 8TB
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.
Dec 9 '08 #10
gits
5,390 Expert Mod 4TB
here is another link that might be of help.
Dec 9 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: petermichaux | last post by:
Hi, Is it possible for an AJAX request to be left open for multiple responses? This could avoid repetitive polling of the server. Thanks, Peter
5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
0
by: arunprabu | last post by:
Hi, I have a problecm with the AJAX request in my webpage. I have some filters on top of the page. I have a submit button and an empty div below the filters. Some of the filters have ajax...
3
by: Simon | last post by:
I have the following code in Javascript which is creating and sending an XMLHttpRequest . <code> var xmlHttp; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlHttp = new...
1
by: nikki.farrah | last post by:
Hi all, this is my first time posting so any help is appreciated! I am doing a simple AJAX request to our server, and I would like the cursor style changed to 'wait' when the user clicks a button...
7
by: Sebarry | last post by:
Hi, I have a Javascript function that creates an Ajax Request object in order to retrieve data from a database using a PHP script. The Javascript function is invoked by another Javascript function...
3
by: mentor | last post by:
When user is authenticated, the server store "UserName" in session. Then throug ajax, the user request another page which require authentication. How the ajax request tell the server that one has...
2
Frinavale
by: Frinavale | last post by:
I have a JavaScript class that displays a partially-opaque div over top of the content of another div when an Ajax request is sent to the server. When the request returns, the JavaScript class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.