我在使用一些 javascript 时遇到了问题。下面的代码片段创建了一个简单的发布请求,但它总是抛出NS_Error_failure
异常(页面底部的详细信息)。谁能告诉我这段代码有什么问题?
window.onload = function () {
alert('0');
try {
var url = "Some URL";
var request = CreateHttpRequest();
if (request) {
alert('1');
request.open("POST", url, false);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
alert('2');
request.send('');
alert('3');
}
}
catch (err) {
alert(err);
}
}
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)"
nsresult: "0x80004005 (NS_ERROR_FAILURE)"
location: "JS frame :: file:///C:/Users/Ben/Desktop/test.html :: <TOP_LEVEL> :: line 44" data: no]