PDA

View Full Version : Best way to add global ajax error handling?



mnadig
8 May 2012, 9:43 AM
Hi, reading over various posts and trying stuff out. However, I still haven't had success attaching a global error handler for my ajax calls.

I read through
http://www.sencha.com/forum/showthread.php?140693-Global-exception-handling-for-data-requests
(http://www.sencha.com/forum/showthread.php?140693-Global-exception-handling-for-data-requests)
in Ext.application{ lauch block:
Ext.util.Observable.observe(Ext.data.Connection);
Ext.data.Connection.on('requestexception', function(dataconn, response, options){

but getting script error

I'm a bit lost. Any help greatly appreciated.

estesbubba
8 May 2012, 9:47 AM
Try this



Ext.Ajax.on({
requestcomplete: this.onRequestComplete,
requestexception: this.onRequestException,
beforerequest: this.onBeforeRequest,
scope: this
});

mnadig
8 May 2012, 9:51 AM
Try this
...

muy bueno! Thanks a ton.

grnadav
4 Oct 2012, 3:38 AM
would this catch Stores\Models network requests or just explicit Ext.Ajax.request s ?

SebasSP
4 Oct 2012, 3:43 AM
Only Ext.Ajax.request if I recall correctly

grnadav
4 Oct 2012, 3:44 AM
bummer
back to overriding Ext.data.Connection then...

venkatesh.R
4 Oct 2012, 5:18 AM
Hi,

Where to add the Code Block in our apps:-?

SebasSP
4 Oct 2012, 5:26 AM
You can add it to the launch function of app.js.

venkatesh.R
4 Oct 2012, 6:06 AM
Hi,

Thanks for your Info.

venkatesh.R
5 Oct 2012, 3:04 AM
Hi,

I have added the above specified code block in launch() function of app.js

But i got Uncaught TypeError: Cannot read property 'fn' of undefined .

any suggestion on this issue.


Thanks