开发者

How do I get the http return code from an XHR object in mootools

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 docum开发者_如何学运维entation that shows the list of members in that object.


just console.info this in the callback onFailure - this.status contains the http error response. this.xhr contains more about the request and extended responses.

http://www.jsfiddle.net/dimitar/NF2jz/365/

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)";
            break;
            case 301:
                error = "Object moved permanently (301 redirect)";
            break;
            case 302:
                error = "Object moved temporarliy (302 redirect)";
            break;
        }
        alert(error);
    }
}).send();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜