PDA

View Full Version : How to get response text from JsonStore callback



errd
30 Mar 2011, 4:15 AM
Hi there!



this.store.load({
params: {
start: 0,
limit: settings.itemsPerPage
},
callback: function(records, options, success){
Ext.get('loading').hide();
Ext.select('body').unmask();
if(!success) {
alert(r.responseText);
}
}
});


I'm confused by server side error handling. If the server returns error string on request, I want to show it to the user, so I need to access response text (r.responseText). How to deal with it?

Thanks!

mitchellsimoens
30 Mar 2011, 6:12 AM
For error handling, put a listener on the Store for the exception event.


new Ext.data.Store({
...
listeners : {
exception: function(proxy, type, action, options, response, arguments) {
//now you can use the response to get the error string
}
}
});

errd
30 Mar 2011, 6:45 AM
Great! It works!