XMLHttpRequestEventTarget.onabort

翻译不完整。 请帮助我们翻译这篇文章!

XMLHttpRequestEventTarget.onabort 会在 XMLHttpRequest 交易操作被诸如 XMLHttpRequest.abort() 函数中止时调用。

语法

XMLHttpRequest.onabort = callback;

  • callback 在交易被中止时调用的函数。

示例

var xmlhttp = new XMLHttpRequest(),
  method = 'GET',
  url = 'https://developer.mozilla.org/';

xmlhttp.open(method, url, true);
xmlhttp.onabort = function () {
  console.log('** 请求被中止');
};
xmlhttp.send();
//..
xmlhttp.abort(); // 这将会调用我们上面定义的 onabort 回调函数

规范

规范 状态 备注
XMLHttpRequest Living Standard WHATWG living standard

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onabortChrome Full support YesEdge Full support ≤18Firefox Full support YesIE Full support 10Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support