這似乎是一個Firefox問題。我在下面寫的代碼在Chrome中完美工作,但在Firefox(12)中完全不起作用;與問題中所述的錯誤相同。
注意:我沒有安裝Firebug。我在Tools/Web Developer中使用了控制檯。
<html>
<head>
<script>
window.onload = function() {
document.write("CORS test");
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
var request = createCORSRequest("GET", "http://a.localhost:25565/");
function doneLoading(rq)
{
document.write(rq.responseText);
}
if (request){
document.write("<br />Requested..<br /><br />");
console.log(request);
request.onload = function() { doneLoading(request) }
// THE ERROR POINTS TO THE ABOVE LINE
request.send();
}
else {
document.write("<br />No request!");
}
}
</script>
</head>
<body>
</body>
</html>
你運行的是哪個版本的Firefox和Firebug?您是否嘗試禁用所有附加組件(Firebug除外)? – j08691 2012-02-29 15:53:12
版本10.0.2 firefox和1.9.1 firebuf,我會嘗試並現在禁用它們。謝謝。 – LeeTee 2012-02-29 16:51:21
我禁用了附加功能,並且錯誤消息已經消失。所以它是一個附加組件。我怎麼知道它是哪一個? – LeeTee 2012-02-29 17:02:00