ここに私の簡単なウェブページがあります:
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="start()">
</body>
</html>
そして、ここに私の XMLHttpRequest があります:
function start(){
//Name the function that will perform request
var httpRequest;
//cross browser instance
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject){ //if IE 8 and older
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
httpRequest.onreadystatechange = httpResult; //what to do after response
httpRequest.open("GET","http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast?pretty", true);
httpRequest.send();
function httpResult(){
if (httpRequest.readyState === 4 && httpRequest.status === 200){
alert(httpResult.responseText);
} else {
alert("problem making request");
}
}
}
ページをロードすると、コードが実行され、「リクエスト作成の問題」アラートが 3 回返されます。JavaScript コンソールにエラー ポップアップが表示されません。リクエストから適切な応答が得られない理由について、誰にも手がかりがありますか?