1

I am using the following function which has worked fine up until now, but I am frequently getting the following error:

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://www.myURL.info/manage/sharedLibrary.js :: getFile :: line 406" data: no]

NOTE error line is indicated below directly after comment in code block.

ADDITIONAL RESEARCH this is apparently a common issue with firefox. Does anyone have a cleaner way to do [this]?1

The function has worked perfectly up until now and 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 line 406 in the error code.
            AJAX.send(null);
            return AJAX.responseText;
        }else{
            return false;
        }
    }catch(err){
        var a = prompt("", err);
    }
}

I am using firefow as my browser. if I crash Firefox and relaunch the error is no longer present yet does resurface after a bit of time. The use case is not totally precise.

Is there some variable I should be resetting with each request?

If I try and catch, the error seems to break some underlying functionality that is not reset until the browser is relaunched.

Any help would be appreciated!

4

1 回答 1

0

尝试

AJAX.onreadystatechange = function(){ var text = AJAX.responseText};

AJAX.send(null);
于 2012-07-26T06:49:29.970 回答