A RetroSearch Logo

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

Search Query:

Showing content from https://webplatform.github.io/docs/apis/xhr/XMLHttpRequest/abort below:

abort ยท WebPlatform Docs

abort Summary

Stops an asynchronous XMLHttpRequest in progress.

Method of apis/xhr/XMLHttpRequestapis/xhr/XMLHttpRequest

Syntax
 .abort();
Return Value

No return value

Examples
function request() {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://localhost/test.xml", true);
    xhr.send();
    return xhr;
}

document.getElementById('submit').addEventListener('click', function () {
    var xhr = request(),
        submit = this,
        cancel = document.getElementById('cancel');

    function detach() {
        submit.removeEventListener('click', canceling, false);
        cancel.removeEventListener('click', canceling, false);
    }

    function canceling() {
        detach();
        xhr.abort();
    }

    
    xhr.addEventListener('load', detach, false);

    
    submit.addEventListener('click', canceling, false);

    
    cancel.addEventListener('click', canceling, false);
}, false);
Notes

Calling abort resets the object; the readyState is changed to 0 (uninitialized). Calling it on an already aborted request throws an exception.

Related specifications
W3C XMLHttpRequest Specification
W3C Working Draft
Attributions

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