1let xhr = new XMLHttpRequest ();
2xhr.onreadystatechange = function () {
3 if (this.readyState == 4) {
4 clearTimeout(timeout);
5 // do something with response data
6 }
7}
8let timeout = setTimeout( function () {
9 xhr.abort(); // call error callback
10}, 60*1000 /* timeout after a minute */ );
11xhr.open('GET', url, true);
12
13xhr.send();