Aborting Ajax.Request

117 views
Skip to first unread message

Mert Hurturk

unread,
Aug 15, 2008, 8:11:49 AM8/15/08
to Prototype: Core
Hi everyone,

I have found a way to cancel an Ajax.Request. Just wanted to know if
there is an already solution for this, or a better one?

Here is the code:

var axConnection;
new Ajax.Request('sample.php', {
onCreate: function(request) { axConnection = request; },
});
axConnection.transport.abort();


PS: When I abort the connection the way above, Ajax.Request fires
onSuccess event. Is there a way to avoid that?

Thank you!

Mark Caudill

unread,
Aug 27, 2008, 4:12:25 PM8/27/08
to Prototype: Core
There has actually been some goings-on with .abort and timeouts...
Here are some tickets if you're interested:
http://prototype.lighthouseapp.com/projects/8886/tickets/308-major-ajax
http://prototype.lighthouseapp.com/projects/8886/tickets/302-ajax-abort-method

The simplest way to fix onSuccess is check if transport.send() is
false according to specs, but your mileage may vary depending on the
browser. It's worth a short though.

(Though you should direct questions outside of the Core group.)
Reply all
Reply to author
Forward
0 new messages