Currently, I am in the process of developing an AJAX request within a Firefox extension. The following code snippet illustrates my approach:
function GetMenu(){
var oReq = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
// Event handler setup - must occur before calling open()
oReq.addEventListener("progress", updateProgress, false);
oReq.addEventListener("load", transferComplete, false);
oReq.addEventListener("error", transferFailed, false);
oReq.addEventListener("abort", transferCanceled, false);
oReq.open('POST', "http://www.foo.bar/", true);
oReq.send('your=data&and=more&stuff=here');
}
function transferFailed(evt) {
Application.console.log("An error occurred while transferring the file.");
Application.console.log(this.responseText);
for(var i in evt)
Application.console.log(i+ ' => '+evt[i]);
}
The issue arises when trying to execute the request as a result of 's non-existence. This makes me wonder why there is no specific error message provided in the `evt` object that is passed to `transferFailed()`. Shouldn't there be some indication within the event object detailing the nature of the error such as "Domain does not exist" or "DNS failure"? At present, none of the properties of the event object seem to provide any insight into the actual problem.
Shouldn't there be more clarity regarding the underlying cause of the error?