xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
}
上面的代碼來自:http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp。readyState vs status == 200
問:
根據本教程:
readyState: 4: request finished and response is ready
status: 200: "OK"
When readyState is 4 and status is 200, the response is ready:
自當xmlhttp.readyState == 4
,響應準備好了,爲什麼我們還需要xmlhttp.status == 200
? xmlhttp.readyState == 4
和xmlhttp.status == 200
有什麼區別?
正是我所需要的! –