0

仅仅是因为“同源”政策还是编码本身存在问题。我问是因为我对 js 完全陌生!任何帮助,将不胜感激!

<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>
4

2 回答 2

1

你不能做跨域 XMLHttpRequests。这可能是 0 xmlhttp.status 的原因

于 2011-12-29T11:29:05.313 回答
0

您是否在所有浏览器中都获得了状态 0 ?

在 IE 7 等老式的 goldie 浏览器中尝试,并将安全级别设置为最低。

于 2011-12-29T11:34:35.327 回答