Ajax 请求超时和网络异常

上代码 html部分 node.js 部分 再node.js部分设置一个定时器模拟网络延迟 setTimeout(()=>{ response.send(‘延迟响应’); },3000); (在定时器里面设置响应内容) 回到html 设置超时为 2s如果请求超过两秒就取消请求 xhr.timeout = 2000; 超时回调 xhr.ontimeout = function(){ alert(“哎
相关文章
相关标签/搜索