XMLHttpRequestEventTarget.onabort
is the function called when an
XMLHttpRequest
transaction is aborted, such as when the
XMLHttpRequest.abort()
函数被调用。
XMLHttpRequest.onabort = callback;
callback
is the function to be executed when the transaction is aborted.
var xmlhttp = new XMLHttpRequest(),
method = 'GET',
url = 'https://developer.mozilla.org/';
xmlhttp.open(method, url, true);
xmlhttp.onabort = function () {
console.log('** The request was aborted');
};
xmlhttp.send();
//..
xmlhttp.abort(); // This will invoke our onabort handler above
| 规范 | 状态 | 注释 |
|---|---|---|
| XMLHttpRequest | 实时标准 | WHATWG (Web 超文本应用程序技术工作组) 实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onabort
|
Chrome Yes | Edge ≤18 | Firefox Yes | IE 10 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
XMLHttpRequestEventTarget
onabort
onerror
onload
onloadstart
onprogress