急问,请帮忙,谢谢各位大侠!请问http_request.readyState一直为1,到不了4,是什么原因呢?该如何解决呢?谢谢!
ajax后台请求页面,readyState有时能到4,返回数据,有时就一直为1,返回不了数据,怎么办,该如何解决呢?谢谢各位大侠帮忙啊!!!即使是请求同一个页面,也有时能得到4,有时一直为1,代码如下var http_request=false;--------------------编程问答-------------------- --------------------编程问答-------------------- 我写
if(window.XMLHttpRequest){
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){
http_request.overrideMimeType("text/xml");
}
}else if(window.ActiveXObject){
try{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
}
}
}
if(http_request){
http_request.onreadystatechange=getAbc;
http_request.open("GET","/test.jsp" ,true);
http_request.send(null);
}
function getAbc(){
if(http_request.readyState==4){
if(http_request.status==200){
alert("abc");
}
}
}
}
}
alert(printhttp_request.readyState);
if(printhttp_request.readyState==4){
有时弹出
1
1
undefined
undefined
undefined
也有时弹出
1
1
3
4
2
(状态:0 = uninitialized
1 = loading
2 = loaded
3 = interactive
4 = complete
)
请大家帮我分析一下原因及解决方案,多谢了! --------------------编程问答--------------------
补充:Java , Java SE