AJAX超时设置

AJAX超时设置

z_shousi 萌新

直接上代码

1
2
3
4
5
6
7
8
9
10
11
12
var xhr = new XMLHttpRequest (); 
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
clearTimeout(timeout);
// do something with response data
}
}
var timeout = setTimeout( function () {
xhr.abort(); // call error callback
}, 60*1000 /* timeout after a minute */ );
xhr.open('GET', url, true);
xhr.send();
  • 本文标题:AJAX超时设置
  • 本文作者:z_shousi
  • 创建时间:2023-03-18 17:42:12
  • 本文链接:https://blog.hellomt.cn/2023/03/18/AJAX超时设置/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
此页目录
AJAX超时设置