函数loadXMLDocLogout() {
var xmlhttpLogOut;
xmlhttpLogOut=new XMLHttpRequest();
//xmlhttpLogOut.onreadystatechange=function()
{
if (xmlhttpLogOut.readyState==4 && xmlhttpLogOut.status==200)
{
document.getElementById("loadingDiv").style.display="none";
}
else
document.getElementById("loadingDiv").style.display="block";
}
xmlhttpLogOut.open("GET","http://www.mysite.me/logout.php?LogOut=1",false);
xmlhttpLogOut.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttpLogOut.send(null);}
尽管对xmlhttpLogOut.onreadystatechange=function()行进行了注释,但上面的代码工作得很好!
提前感谢您的帮助。
发布于 2011-08-12 20:56:40
上面的代码运行得很好
当然,它是有效的javascript代码。
if (xmlhttpLogOut.readyState==4 && xmlhttpLogOut.status==200)将失败,因此
else
document.getElementById("loadingDiv").style.display="block";将被执行。
但是,它是否会产生与未注释的xmlhttpLogOut.onreadystatechange=function()相同的结果?也就是说,元素被隐藏了(如果它已经可见)?我对此表示怀疑。
你试过所有可能的测试用例了吗?
(首先,在发送loadingDiv请求之前是否隐藏了Ajax div?)
https://stackoverflow.com/questions/7040038
复制相似问题