enyo.Ajax and handling different HTTP error codes

I'd like to be able to distinguish between the different errors that my Web API REST Service might return on a GET (or any verb really).

However, it seems that when using the error(inRequest, inResponse) the inResponse does not have anything other than 400 as a value.

For instance we can see that a 403 has been returned from the server with a text value, however nothing makes it to the error() of the enyo.Ajax.

Is there a way to pick up the HTTP code from within the enyo.Ajax? Something along the lines of what jQuery has with statusCode? http://api.jquery.com/jQuery.ajax/

Comments

  • The inSender argument of your success or error callback is a reference to the original enyo.Ajax object. In that object, you'll find a xhrResponse object that has status, headers, and body fields.

    So, you'd do something like
    myAjax.error(enyo.bind(this, function(inSender, inResponse) {
        alert("HTTP Status is " + inSender.xhrResponse.status);
    }
  • Wow thanks, I was looking at it the wrong way. Appreciate the help!
Sign In or Register to comment.