JavaScript中如何取消ajax请求

上传:dongjtu 浏览: 23 推荐: 0 文件:PDF 大小:58.83KB 上传时间:2021-01-09 20:18:18 版权申诉
JS xmlHttp.open(POST,theUrl,true); xmlHttp.onreadystatechange=function(){ ...//得到响应之后的操作 } xmlHttp.send(); //设置8秒钟后检查xmlHttp对象所发送的数据是否得到响应. setTimeout(CheckRequest(),8000); function CheckRequest(){ //为4时代表请求完成了 if(xmlHttp.readyState!=4){ alert('响应超时'); //关闭请求 xmlHttp.close(
上传资源
用户评论