PDA

View Full Version : ajax request exception handling



javapurna
15 Jun 2013, 2:56 AM
hi every one.

how to handle ajax request exception . i am using ajax request on store . i want to handle request is send(beforerequest) and requestcomplete and requestexception globally . how to do.

please some on provide any examples project url.

what is connection in Ext.ajax.request.on(connection,res,opts)

slemmon
16 Jun 2013, 11:24 PM
See if the below example helps point you in the right direction:
*console.log(conn) to see exactly what it makes available to you. conn will be an instance of Ext.data.Connection (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Connection)



Ext.Ajax.on('requestexception', function (conn, response, options) {
if (response.status === 403) {
window.location = 'login';
}
});

javapurna
17 Jun 2013, 3:08 AM
ok, if any exception is raised on any store that is ajax request i want to execute

Ext.Ajax.on('requestexception', function (conn, response, options) { if (response.status === 403) { window.location = 'login'; }});.how can make this global . where to put this code app.js or application or my viewport

slemmon
17 Jun 2013, 12:56 PM
If you have an Ext.application I would put it in the application's init method:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.app.Application-method-init