A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/abort below:

XMLHttpRequest: abort() method - Web APIs

XMLHttpRequest: abort() method

Baseline Widely available

Note: This feature is available in Web Workers, except for Service Workers.

The XMLHttpRequest.abort() method aborts the request if it has already been sent. When a request is aborted, its readyState is changed to XMLHttpRequest.UNSENT (0) and the request's status code is set to 0.

If the request is still in progress (its readyState is not XMLHttpRequest.DONE or XMLHttpRequest.UNSENT), a readystatechange event, abort, and a loadend event are dispatched, in that order. For synchronous requests, no events are dispatched and an error is thrown instead.

Syntax Parameters

None.

Return value

None (undefined).

Examples

This example begins loading content from the MDN home page, then due to some condition, aborts the transfer by calling abort().

const xhr = new XMLHttpRequest();
const method = "GET";
const url = "https://developer.mozilla.org/";
xhr.open(method, url, true);

xhr.send();

if (OH_NOES_WE_NEED_TO_CANCEL_RIGHT_NOW_OR_ELSE) {
  xhr.abort();
}
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4