[Dojo-interest] dealing with XHR error code

Luke Saunders luke.saunders.lists at googlemail.com
Sun Aug 26 12:27:56 UTC 2007


That's useful, I might use that. Is it not unsafe to use the private attr
dojo._contentHandlers in my code though (since the internals might change)?

Anyway, I've opened ticket #4295 as suggested. Thanks for the help guys.

On 8/26/07, James Burke <jburke at dojotoolkit.org> wrote:
>
> You could use the following (works for whatever handleAs value you
> passed into the XHR call.
>
> error: function(result, ioArgs){
>     var parsedResult = dojo._contentHandlers[ioArgs.handleAs](ioArgs.xhr);
> }
>
> If you would like this to be more automatic/done by the interior Dojo
> code, feel free to open a ticket at http://trac.dojotoolkit.org (use
> guest/guest account).
>
> James
>
> On 8/25/07, Luke Saunders <luke.saunders.lists at googlemail.com> wrote:
> > Normally when doing XHR, if the request is invalid (like if a field is
> > missing or even if there's an incorrect password) I have the API respond
> > with an error code (400 usually) and some JSON as the response body
> normally
> > containing a reason for the error so the front end can deal with it
> nicely,
> > like give the user a meaningful message.
> >
> > However, when using dojo.xhrGet() the response is just an Error object
> if an
> > error response code is returned, the only way to get to the actual JSON
> > response is to parse ioArgs.xhr.responseText which is horrible compared
> to
> > just getting the JSON object as the response as is the case with a
> > successful request.
> >
> > Have I got this right? What's the best way to handle this?
> >
> > _______________________________________________
> > FAQ: http://dojotoolkit.org/support/faq
> > Book: http://dojotoolkit.org/docs/book
> > Forums: http://dojotoolkit.org/forum
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
> >
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dojotoolkit.org/pipermail/dojo-interest/attachments/20070826/d2a01751/attachment-0001.html 


More information about the Dojo-interest mailing list