Deferred implementation for jQuery Ajax global handlers -


according jquery documentation, global ajax event handlers must implemented using callback functions on document. otherwise, local $.ajax() implement events using promises.

is there way of handling global ajax events using promises method, .done(), .fail(), .always() , .then() ?

i'm looking way declaring event handlers global ajax events not depend on $(document), example:

// current way of doing this: // $(document).ajaxsuccess(_handleajaxsuccess); //  // ideas of like: // $.ajaxsuccess(_handleajaxsuccess); // $.ajax.done(_handleajaxsuccess); // $.ajaxsetup({ done: _handleajaxsuccess }); 

no, cannot handle global ajax events using promises method .done(), .fail(), .always() , .then().

those promise methods, therefore promise needs exist before before become available.

by definition, jquery's global ajax event handlers not attached particular promise @ point defined. instead, stored jquery , invoked internally whenever ajax events occur.

as users of jquery, don't need worry how internal invocations made can pretty sure 1 or other of methods .done(), .fail(), .always() , .then() involved.

if want know more, can delve jquery source, doubt understanding particularly valuable.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

dataset - MPAndroidchart returning no chart Data available -

post - imageshack API cURL -