PDA

View Full Version : Override default AJAX error handler



Perceptive
24 Sep 2010, 2:50 AM
Hi,

I have a default error handler which I want to use for most Ext.Ajax.requests:

Ext.Ajax.on('requestexception',function(conn, response, options){
//show error message etc....
}

However, I have one Ajax request that I want to use a different error handler for:

Ext.Ajax.request({
url: 'php/includes/sessionhandler.php',
method: 'post',
params: request,
failure: function(response, options){
console.log('customhandler');
clearInterval(timers.sessionChecker);
var response = Ext.util.JSON.decode(response.responseText);
switch(response.message){
case 'Unauthorised - session timed out.':
if($('#loginForm').length==0){
validate_user_oracle('timeout','Session Timed Out');
}
break;
case 'Unauthorised - session details incorrect.':
//window.location ='index.php?unauthorised';
break;
}
return false;
}
});

However, the problem is that when an error occurs with the above request, BOTH the default AND custom error handlers fire. The default error handler fires before the custom error handler. How do I completely override the default error handler?

Thanks for your help!

Animal
24 Sep 2010, 6:01 AM
Well don't use the Ajax singleton then. Use an instance of Ext.data.Connection.

Perceptive
24 Sep 2010, 6:06 AM
Thanks! I'll try that...