function 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);
}
The above code works perfectly despite of line xmlhttpLogOut.onreadystatechange=function() being commented!
Thanks for help in advance.
The above code works perfectly
Of course it will, it is valid javascript code.
The if (xmlhttpLogOut.readyState==4 && xmlhttpLogOut.status==200)
will fail and so
else
document.getElementById("loadingDiv").style.display="block";
will be executed.
But does it produce the same result as the xmlhttpLogOut.onreadystatechange=function() not being commented? That is the element getting hidden (if it is already visible)? I doubt.
Did you try all possible test cases?
(To begin with, was the loadingDiv
div hidden before the Ajax request was sent?)
精彩评论