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/readystatechange_event below:

XMLHttpRequest: readystatechange event - Web APIs

XMLHttpRequest: readystatechange event

Baseline Widely available

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

The readystatechange event is fired whenever the readyState property of the XMLHttpRequest changes.

Warning: This should not be used with synchronous requests and must not be used from native code.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener("readystatechange", (event) => { })

onreadystatechange = (event) => { }
Event type

A generic Event with no added properties.

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

xhr.open(method, url, true);
xhr.onreadystatechange = () => {
  // In local files, status is 0 upon success in Mozilla Firefox
  if (xhr.readyState === XMLHttpRequest.DONE) {
    const status = xhr.status;
    if (status === 0 || (status >= 200 && status < 400)) {
      // The request has been completed successfully
      console.log(xhr.responseText);
    } else {
      // Oh no! There has been an error with the request!
    }
  }
};
xhr.send();
Specifications Browser compatibility

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