覆盖Ajax.js与监听requestexception不工作 [英] override Ajax.js with listener for requestexception not working
问题描述
这是包含在一个需要在主应用程序语句。它加载的Ajax然后死。我使用 ExtJS的5,code是在UI /一个覆盖文件夹中。它似乎无法找到code文件夹在同一级别的应用程序。
Ext.define(Ext.overrides.Ajax',{
覆盖:自Ext.data.Connection,
听众 : {
requestexception:功能(响应){
VAR错误= response.status +' - '+ response.statusText;
//如果响应状态是202(接受),应
//有警告信息
如果(response.status == 202){
Ext.Msg.show({
标题:REST警告信息,
味精:Ajax请求例外! +错误,
CLS:MSG-包装,
按键:Ext.Msg.OK,
图标:Ext.Msg.WARNING
});
}
如果(response.status> 400){
VAR errordata子= Ext.JSON.de code(response.responseText);
Ext.Msg.show({
标题:REST错误消息,
味精:Ajax请求例外! + errordata子,
CLS:MSG-包装,
按键:Ext.Msg.OK,
图标:Ext.Msg.ERROR
});
}
}
}
});
我也有类似的问题。在ExtJS的4,我有一个Ext.Ajax的替代配置,就像你的。
要得到它与ExtJS的5工作,我读 HTTP:/ /www.sencha.com/blog/top-support-tips-october-2014 并成功地改变了我的覆盖结构如下:
Ext.define(Ext.override.AjaxOverride',{
覆盖:Ext.Ajax的
//省略覆盖性能...
}, 功能() {
VAR我=这一点;
me.setExtraParams({
富:栏
});
me.setUrl('MyUrl');
me.setTimeout(600000);
我上({
适用范围:我,
requestexception:功能(康涅狄格州,反应,选择采用){
//我的异常处理
}
});
});
This is included in a requires statement in the main app. It loads Ajax then dies. I'm using Extjs 5. The code is in an overrides folder under ui/. It can't seem to find the code in a folder at the same level as app.
Ext.define('Ext.overrides.Ajax', {
override : 'Ext.data.Connection',
listeners : {
requestexception : function(response) {
var error = response.status + ' - ' + response.statusText;
// if response status is 202 (Accepted), should
// have warning message
if (response.status == 202) {
Ext.Msg.show({
title : 'REST Warning message',
msg : 'Ajax Request Exception! ' + error,
cls : 'msg-wrap',
buttons : Ext.Msg.OK,
icon : Ext.Msg.WARNING
});
}
if (response.status > 400) {
var errorData = Ext.JSON.decode(response.responseText);
Ext.Msg.show({
title : 'REST Error message',
msg : 'Ajax Request Exception! ' + errorData,
cls : 'msg-wrap',
buttons : Ext.Msg.OK,
icon : Ext.Msg.ERROR
});
}
}
}
});
I had a similar issue. In ExtJS 4, I had a Ext.Ajax override configured just like yours.
To get it to work with ExtJS 5, I read http://www.sencha.com/blog/top-support-tips-october-2014 and successfully changed my override structure to the following:
Ext.define('Ext.override.AjaxOverride', {
override: 'Ext.Ajax'
// omitted overridden properties...
}, function() {
var me = this;
me.setExtraParams({
foo: "bar"
});
me.setUrl('MyUrl');
me.setTimeout(600000);
me.on({
scope: me,
requestexception: function(conn, response, opts) {
// my exception handling
}
});
});
这篇关于覆盖Ajax.js与监听requestexception不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!