According to jQuery documentation, the global Ajax event handlers must be implemented using callback functions on the document. Otherwise, local $.ajax() implement events using promises.
Is there any way of handling the global Ajax events using promises method, as .done(), .fail(), .always() and .then() ?
I'm looking for a way for declaring event handlers for global ajax events that do not depend on $(document)
, for example:
// current way of doing this:
// $(document).ajaxSuccess(_handleAjaxSuccess);
//
// some ideas of what it could look like:
// $.ajaxSuccess(_handleAjaxSuccess);
// $.ajax.done(_handleAjaxSuccess);
// $.ajaxSetup({ done: _handleAjaxSuccess });