javascript – How do I get the http return code from an XHR object in mootools – Education Career Blog

I am doing an AJAX request. In my onFail event of the Request I catch the XHR object.
What is the name of the member in this object that holds the code.
For that mater, I could not find a documentation that shows the list of members in that object.


just this in the callback onFailurethis.status contains the http error response. this.xhr contains more about the request and extended responses.

new Request({
    url: '/secho/html/',
    data: {
        html: "<p>Text echoed back to request</p>" + "<script type='text/javascript'>$('target').highlight();<\/script>",
        delay: 3
    method: 'post',
    onFailure: function() {
        var error = "Error " + this.status;
        switch (this.status) {
            case 404:
                error = "Document not found (404)";
            case 301:
                error = "Object moved permanently (301 redirect)";
            case 302:
                error = "Object moved temporarliy (302 redirect)";

Leave a Comment