XMLHttpRequest: timeout event

The timeout event is fired when progression is terminated due to preset time expiring.

Bubbles No
Cancelable No
Interface ProgressEvent
Event handler property XMLHttpRequestEventTarget.ontimeout

Examples

const client = new XMLHttpRequest();
client.open('GET', 'http://www.example.org/example.txt');
client.ontimeout = () => {
    console.error('Timeout!!')
};

client.send();

You could also set up the event handler using the addEventListener() method:

client.addEventListener('timeout', () => {
    console.error("Timeout!!");
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
timeout_event
29
12
12
8
16
7
≤37
29
14
16
7
1.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout_event