Closed aglemann closed 13 years ago
I'd rather use onsuccess / onerror callbacks to keep success and error logic away from each other.. any specific reason (cross platform support or..?) for missing this behaviour?
perhaps doing this in /src/js/xhr.js:
+++ if((/^[45]/).test(req.status)) req.handleError(req); // pass XHR object (req) to handleError --- if((/^[45]/).test(req.status)) req.handleError();
would allow to access XHR object in xhr.error method lile:
trigger.xhr(this.parentNode.action, { method: 'post', error: function(xhr) { if (xhr.status == 401) { // not authorized location.href = '/login'; } }, ...
I have done this in my fork and it seem to work. What's the way for this to land in origin here?
best way would be to fork at github.com/xui/xui and submit a pull request.
Only executes the callback if status OK, should pass the status as first param to callback and always execute on completion (no handling for when the request goes bad).
Thanks!