views:

162

answers:

2

Simple question, but not obvious from the Mozilla JS docs. Anyone know the answer off the top of their head?

+2  A: 

Here's the standard implementation. Based on below, the only way is to check the readyState of the object, however this won't work in all browsers.

Syntax

XMLHttpRequest.abort() Return Value

No return value.

Remarks

abort was introduced in Windows Internet Explorer 7.

The abort method interrupts an asynchronous operation in progress. (Pass true to the varAsync parameter of open to create an asynchronous request.)

Calling abort resets the object; the onreadystatechange event handler is removed, and readyState is changed to 0 (uninitialized).

Source

Ian Elliott
+1  A: 

W3C Spec, "The XMLHttpRequest Object":

http://www.w3.org/TR/XMLHttpRequest/

Shortcut to the abort() method:

http://www.w3.org/TR/XMLHttpRequest/#abort

Under the heading "Exceptions for the XMLHttpRequest Object" it says this:

The ABORT_ERR exception is raised when the user aborts a request in synchronous requests.

karim79