Ajax中的代码解释?xmlHttp.readyState==4和xmlHttp.readystate==4大小写有关系吗?if(xmlHttp.readyState==4){alert(xmlHttp.status) ;if(xmlHttp.status==200){// document.getElementById("tData").innerHTML = xmlHttp.responseText ;var logMessage =
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/28 07:25:21
![Ajax中的代码解释?xmlHttp.readyState==4和xmlHttp.readystate==4大小写有关系吗?if(xmlHttp.readyState==4){alert(xmlHttp.status) ;if(xmlHttp.status==200){// document.getElementById(](/uploads/image/z/10966888-64-8.jpg?t=Ajax%E4%B8%AD%E7%9A%84%E4%BB%A3%E7%A0%81%E8%A7%A3%E9%87%8A%3FxmlHttp.readyState%3D%3D4%E5%92%8CxmlHttp.readystate%3D%3D4%E5%A4%A7%E5%B0%8F%E5%86%99%E6%9C%89%E5%85%B3%E7%B3%BB%E5%90%97%3Fif%28xmlHttp.readyState%3D%3D4%29%7Balert%28xmlHttp.status%29+%3Bif%28xmlHttp.status%3D%3D200%29%7B%2F%2F+document.getElementById%28%22tData%22%29.innerHTML+%3D+xmlHttp.responseText+%3Bvar+logMessage+%3D)
if(xmlHttp.readyState==4){
alert(xmlHttp.status) ;
if(xmlHttp.status==200){
// document.getElementById("tData").innerHTML = xmlHttp.responseText ;
var logMessage = xmlHttp.responseText.Trim() ;
if(logMessage!="error"){
window.location = "index.jsp" ;
}else{
alert("用户名或密码有误,重新输入.") ;
window.location = "login.jsp" ;
}
}
}
我原来在我的机子上写的都是xmlHttp.readystate==4运行没有问题,可是现在在现在的机子上就运行不了,换成xmlHttp.readyState==4才运行得了,原来能够运行那也是事实啊,为什么会这样啊?
Ajax中的代码解释?xmlHttp.readyState==4和xmlHttp.readystate==4大小写有关系吗?if(xmlHttp.readyState==4){alert(xmlHttp.status) ;if(xmlHttp.status==200){// document.getElementById("tData").innerHTML = xmlHttp.responseText ;var logMessage =
给你个详细的解释吧.
readyState表示XMLHttpRequest对象的处理状态:
0:XMLHttpRequest对象还没有完成初始化.
1:XMLHttpRequest对象开始发送请求.
2:XMLHttpRequest对象的请求发送完成.
3:XMLHttpRequest对象开始读取服务器的响应.
4:XMLHttpRequest对象读取服务器响应结束.
另:在IE(即Internet Explorer)浏览器中可以不区分大小写,但在其他浏览器中将严格区分大小写.所以为了保证更好的跨浏览器效果,建议采用严格区分大小写的形式.