I want to write a listener that will listen to all network requests errors, something like this :
Ext.Ajax.on('requestexception', function(conn, response, options) {
if (response.status === 555) {
Ext.Msg.alert('test', 'test');
}
});
The above code works only for requests via Ext.Ajax.request(), how to rewrite it so it could work also for form submits, url not found error etc.
On server side I have Spring MVC that dispatches all requests and if there is any error, the response status of 555 is returned.
form.submit({
url: dispatcher.getUrl('savePlanRequest'),
//headers: {'Content-Type':'multipart/form-data; accept-charset=utf-8'},
scope: this,
method: 'GET',
params: {
scan: scan_id,
attachments: attachments_id,
parcels: parcels_id
},
success: function(form, action) {
this.fireEvent('plansaved', this);
Ext.Msg.alert(i18n.getMsg('success'), i18n.getMsg('gsip.view.plans.NewPlanForm.success_info'))
},
failure: function(form, action) {
console.log('failure');
//Ext.Msg.alert(i18n.getMsg('failure'), action.result.msg);
}
});
This should work:
Have a look at the source code for the exact
handleResponse()method from which I copied most of the code above.