为什么xmlhttp.status始终为0?

问题描述:

仅仅是因为“同源”政策还是因为编码本身存在某些问题。我问,因为我对js是全新的!任何帮助,将不胜感激!为什么xmlhttp.status始终为0?

<html> 
<head> 
<script type="text/javascript"> 
function loadXMLDoc() 
{ 
var xmlhttp= new XMLHttpRequest(); 
xmlhttp.onreadystatechange=function() 
    { 

    if (xmlhttp.readyState==4 && xmlhttp.status==200) 
    { 
     document.getElementById("myDiv").innerHTML=xmlhttp.responseText; 
    } 
    } 
xmlhttp.open("GET","https://sb-ssl.google.com/safebrowsing/api/lookup?client=demoapp&apikey=KEY&appver=1.5.2&pver=3.0&url=http%3A%2F%2Fklairproducts.com%2Fwp-content%2Fademins.html",true); 

xmlhttp.send(); 

} 

</script> 
</head> 
<body> 

<div id="myDiv"><h2>is the link phishing?</h2></div> 
<button type="button" onclick="loadXMLDoc()">Lets see</button> 

</body> 
</html> 

你不能这样做跨域XMLHttpRequests.Thas可能是0 xmlhttp.status

+0

您可以发送请求,没问题。但是你无法访问响应。 – user123444555621 2011-12-29 11:32:24

的reasone你得到所有浏览器的状态0?

在像IE 7这样的oldy goldie浏览器中尝试它,并将安全级别设置为最小。