JavaScript中如何取消ajax请求

dongjtu 22 0 PDF 2021-01-09 20:01:17

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(

用户评论
请输入评论内容
评分:
暂无评论