我正在为 Firefox 编写扩展,它使用page-mod
模块来运行包含以下内容的 JavaScript 文件:
function handleServerResponse() {
if (xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
//some code
}
else {
alert("Error during AJAX call. Please try again");
}
}
}
var xmlHttp = new XMLHttpRequest();
var txtname = document.getElementById("txtname");
xmlHttp.open("POST","http://localhost:8080/Jelly/GetStuff",true);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send("url=" + document.URL);
我不断得到xmlhttp.status==0
而不是200
,即使localhost
我使用 IP 地址而不是。有任何想法吗?