I am having trouble with some javascript. The code snippet below creates a simple post request however it always throws an NS_Error_failure
exception (details at the bottom of the page). Can anyone tell me whats wrong with this code?
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]
我发现了同样的问题,当我将所有内容发送到iframe时,当我向标记添加“名称”时,问题就解决了,也许您的脚本无法访问目标
<iframe id="iframe_execute" name="iframe_execute" frameborder="1" height="400" width="400"></iframe>
This error can be seen if there are,
There is not any visible problem in code you shared. Please refer this link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.