I have been successfully using the following function, but recently I keep encountering this error:
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: :: getFile :: line 406" data: no]
NOTE: The line causing the error is identified below in the code block.
FURTHER RESEARCH: It seems this issue is common with Firefox. Is there a better way to handle [this]? 1
The function that has been working fine until now is as follows:
function getFile(url){
var AJAX = null;
try{
if(window.XMLHttpRequest){
AJAX = new XMLHttpRequest();
}else{
AJAX = new ActiveXObject("Microsoft.XMLHTTP");
}
if(AJAX){
AJAX.open("GET", url, false);
//The line below is where the error occurs (line 406).
AJAX.send(null);
return AJAX.responseText;
}else{
return false;
}
}catch(err){
var a = prompt("", err);
}
}
I am using Firefox as my browser. Interestingly, the error disappears when I restart the browser but reappears later on. The pattern is unpredictable.
Should I reset any specific variables with each request?
Using try and catch for error handling breaks some functionality that only resets upon browser restart.
Any guidance on resolving this issue would be highly appreciated!