代码如下,不知道各位有没有遇见过这种问题。代码不是运行在IE里,是widget。开发文档里写的支持javascript,但是用ajax请求数据时,有时候就会出xhr.status = -1 的情况,其他时候正常返回status =200 。请各位大侠帮忙解答function getNews(id,url,type,sort)
{
var xhr;
//call the right constructor for the browser being used
if (window.ActiveXObject)
xhr = new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest)
xhr = new XMLHttpRequest();
else
alert("AJAX request not supported");

//prepare the xmlhttprequest object
xhr.open("GET", url, true);
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4)
{
if (xhr.status == 200)
{
if (xhr.responseText != null)
{
//process sina news
processNews(xhr.responseXML, id,type,sort,url);
}
else
{
alert("Failed to receive RSS file from the server - file not found.");
return false;
}
}
else
{
alert("Error code " + xhr.status + " received: " + xhr.statusText);
}
}
}
//send the request
xhr.send(null);
}