diff --git a/README.md b/README.md index 9397d40..4b6df82 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,36 @@ ajax.raw('/foo').then(function(result) { }); ``` +Error Handling +-------------- + +You can handle errors per each request as follows. Note that the jQuery response object for the error is accessible via `.jqXHR`: + +```js +ajax("my/path", { + data: data +}).then(function(response) { + return console.log(response.message); +}, function(error) { + return doSomething(error.jqXHR.responseJSON); +}); +``` + +Global AJAX error handling can also be implemented using jQuery (does not require this plugin): + +```js +ApplicationRoute = Em.Route.extend({ + init: function() { + this._super(); + return Em.$(document).ajaxError(function(evt, jqxhr) { + return console.log(evt); + }); + } +}); + +export default ApplicationRoute; +``` + Simplified Testing ------------------