我在使用XMLHttpRequest下载渐进式数据时遇到了问题。状态先是2,然后是3。在状态3之后,它就再也没有被调用过了。我做错了什么?我在某个地方读到需要刷新数据,但我该如何做呢?
这是我的代码:
var xmlHttp = new XMLHttpRequest();
// try to connect to the server
try
{
// initiate server request
xmlHttp.open("GET", "http://208.43.121.133:8164/;", true);
xmlHttp.setRequestHeader("Icy-Metadata", "1");
xmlHttp.onreadystatechange = function()
{
alert("status: "+xmlHttp.status);
alert("State: "+xmlHttp.readyState);
if (xmlHttp.readyState == 3)
{
alert(xmlHttp.responseText);
}
};
xmlHttp.send(null);
}
// display an error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
当 readyState 为 3 时,我可以阅读 xmlHttp.responseText 吗?