2011-12-29 16 views
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> 

答えて

1

あなたはおそらく0 xmlhttp.status

+0

リクエストを送信することはできますが、問題はありません。しかし、あなたはその応答にアクセスすることはできません。 – user123444555621

0

ためreasoneをクロスドメインXMLHttpRequests.Thasを行うことができない、あなたはすべてのブラウザでのステータス0を取得しましたか?

IE 7のような古いゴージャスなブラウザで試して、セキュリティレベルを最小に設定してください。

関連する問題