Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  180] [ 2]  / answers: 1 / hits: 59302  / 12 Years ago, tue, june 26, 2012, 12:00:00

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]

More From » javascript

 Answers
31

This error can be seen if there are,




  1. URL not found

  2. There is error in your server code or called URL.



There is not any visible problem in code you shared.
Please refer this link


[#84667] Sunday, June 24, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cody

Total Points: 679
Total Questions: 111
Total Answers: 111

Location: Czech Republic
Member since Thu, Aug 11, 2022
2 Years ago
;