当前位置:编程学习 > XML/UML >>

xmlhttp.status == 200和xmlhttp.readyState == 4 的区别是什么

问下xmlhttp.status == 200和xmlhttp.readyState == 4 的区别是什么,为什么两者要同时判断啊

xmlhttp.readyState == 4  是表示后台处理完成了。
xmlhttp.status == 200 是表示处理的结果是OK的。

 

你是本地file测试的吧。。这样status为0,返回200或者5000,404状态状态需要搭建服务器访问才会返回200或者500,404状态

成功判断200或者0状态就行了,转向不用判断的,会自动返回最后跳转的网址的状态

if(xmlhttp.status == 200  || xmlhttp.status == 0) {         
document.getElementById('divTip').innerHTML = xmlhttp.responseText;
}

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,