我想写一个listener
会监听所有网络请求错误的东西,像这样:
Ext.Ajax.on('requestexception', function(conn, response, options) {
if (response.status === 555) {
Ext.Msg.alert('test', 'test');
}
});
上面的代码仅适用于通过的请求Ext.Ajax.request()
,如何重写它以便它也适用于表单提交、url not found 错误等。
在服务器端,我有调度所有请求的 Spring MVC,如果有,则返回error
的响应状态。555
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);
}
});