I'm trying to handle session timeout server-side.
When getting session timeout, my server sends back a response with json
{success: false}, ContentType: 'application/json', ResponseNo: 408
store:
var storeAssets = Ext.create('Ext.data.Store', {
model : 'modCombo',
autoLoad : false,
proxy : { limitParam : undefined,
startParam : undefined,
paramName : undefined,
pageParam : undefined,
noCache : false,
type : 'ajax',
url : '/caricaAssets.json',
reader : { root : 'data' }
}
});
And on the client side, I handle callback loading store like this:
storeAssets.load({
scope: this,
callback: function(records, operation, success) {
if (!success) { Ext.Msg.alert('Error'); }
}
});
To perform different responses, I'd like to change alert.
So, if response no. is 408
, I can alert session expired
(and so on, managing response numbers).
But I didn't find any way to get response no. in store callback!
Any suggestions?
I know this question is pretty "old", but in ExtJS 4.2.2, when
happens, you can automatically catch the server response using
b.error.status
I don't know if it was implemented only a few time ago (after this was posted I mean), but still it can help anyone checking this post in the future I guess...
Try this (on extjs 4.2.2)
Unfortunately, the callback method does not have the server response passed in as a parameter. This is likely since there are many ways to load data into a store, and not all of them will have a server response.
You can override the proxy's processResponse function to store the server's response with the operation object, then access it in your callback.
Then, to get the status:
I know this is quite old now, but I had a similar problem. The solution I found was to listen for the exception event in the proxy.
I also predicated my store load callback to only proceed when success is true. Hopefully someone else searching will find this helpful.
Solved adding following code:
When i call ajax request, server gives back information that are catched by this exception. Now I can handle callback code!