jQuery: The Write Less, Do More JavaScript Library

How to cancel an ajax request?

View: New views
2 Messages — Rating Filter:   Alert me  

How to cancel an ajax request?

by laredotornado@zipmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

Not sure if this is possible but wanted to float this out there.  Is
there a way to cancel an AJAX request once the ball is set in motion?
I'm using the "$.ajax" call, not sure if there are parameters I can
pass or things I can catch that would help me cancel the request at
some later point.

Thanks for your input, - Dave

Re: How to cancel an ajax request?

by Ariel Flesler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This should do:

var xhr = $.ajax({....});
//...
xhr.abort();

There small issues with this, they were fixed on trunk but I don't
think they made it to 1.2.6.
In short, this is how.

--
Ariel Flesler
http://flesler.blogspot.com

On 24 jul, 12:10, "laredotorn...@..."
<laredotorn...@...> wrote:
> Hi,
>
> Not sure if this is possible but wanted to float this out there.  Is
> there a way to cancel an AJAX request once the ball is set in motion?
> I'm using the "$.ajax" call, not sure if there are parameters I can
> pass or things I can catch that would help me cancel the request at
> some later point.
>
> Thanks for your input, - Dave