Simple Push API を実装しようとしていて、クロスオリジンの XMLHttpRequest を実行しようとしています。私はテストを行っています:
function sendEndPoint() {
var MAXIMUM_WAITING_TIME = 6000;
if (!window.XMLHttpRequest) {
addDebugMessage("XMLHttpRequest not supported.");
} else {
addDebugMessage("XMLHttpRequest supported!");
var xhReq = new XMLHttpRequest({
mozAnon: true,
mozSystem: true
});
xhReq.open("get", "http://192.168.1.69/ping/index.php", true); // Server stuck in a loop.
//Request timeout.
var requestTimer = setTimeout(function () {
xhReq.abort();
addDebugMessage("Error timeout: time was " + MAXIMUM_WAITING_TIME);
}, MAXIMUM_WAITING_TIME);
//It's ready.
xhReq.onreadystatechange = function () {
if (xhReq.readyState != 4) {
return;
}
clearTimeout(requestTimer);
if (xhReq.status != 200) {
addDebugMessage("Error in request.");
return;
}
var serverResponse = xhReq.responseText;
};
}
}
どこで http:// 192 . 168. 1. 69/ping/index.php これは単なる hello world メッセージであり、Firefox OS デバイスの Web ブラウザーを使用してアクセスできます。
いつもタイムアウト エラーが発生します。どれだけ待っても問題ありません。なぜですか?
ありがとう。