87,997
社区成员




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);
}