PDA

View Full Version : Check ajax response on all ajax request



sofway
13 Nov 2010, 8:07 AM
Hi,
I need to check all the ajax responses of the application to check if a value exists but i dont want to include this check on all ajax request. It is like an Aspect Oriented feature.

The ext-basex can do this for me but dont want to depend of this library.
Any advice?

Thanks

plalx
13 Nov 2010, 8:46 AM
You can add an event handler directly on the Ext.Ajax singleton.

E.g.


Ext.Ajax.on('requestcomplete', function(conn, response, options) { ... });


You can also create a function that you will use together with createInterceptor when defining your callback functions.

E.g.


App.ajaxValueCheck = function(...) {...};

Ext.Ajax.request({
success: (function(...) {...}).createInterceptor(App.ajaxValueCheck)
});