Closed Bug 913762 Opened 11 years ago Closed 6 years ago

Unwanted behavior async XHR request that targets a local 404

Categories

(Firefox OS Graveyard :: Gaia::System, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: lcf.vs, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0 (Beta/Release)
Build ID: 20130814063812

Steps to reproduce:

I'm trying to call a non-existing local file in a web-app package.

`var ajax, onload;
        
ajax = function ajax(options) {
    var uri, method, xhr;
            
    uri = options.uri;
    method = options.method;
            
    xhr = new XMLHttpRequest();
    xhr.open(method, uri, options.async || true);
        
    if (method === 'post') {
        xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    }
      
    xhr.onload = onload.bind(xhr, options.callback);
    xhr.onerror = alert.bind(window, 'Never reached 404');

    try {
        xhr.send(options.body || null);
    } catch (error) {
        alert('this error has been threw : ' + error)
    }
};
    
onload = function onload(callback) {
    if (this.readyState === 4) {
        if (this.status === 200) {
            callback(this.responseText);
        } else {
            alert('Never reached 404');
        }
    }
};`

ajax({
    method: 'get',
    uri: 'non-existing-file',
    callback: function (responseText) {
        alert(responseText);
    }
});


Actual results:

An error is thrown when calling xhr.send()


Expected results:

According to the documentation, the onload event should be called if a 404 is encountered, but this is not the case.

So I tried using the onerror event, same result.
Firefox OS is not being worked on
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.