ajax communication failed,extjs - How do I extend Ext.Ajax? - Stack Overflow

I use it quite often in an app I am making, so I would like to shorten it up if I can and make an extended class to handle all the callback logic in one place, I tried setting it up like this but fails when trying to load the class with:

Uncaught TypeError: Cannot read property 'isInstance' of undefined ext-all-debug.js:4136

ExtClass.registerPreprocessor.config ext-all-debug.js:4136

Ext.apply.doProcess ext-all-debug.js:4007

Manager.registerPostprocessor.uses ext-all-debug.js:6037

Ext.apply.require ext-all-debug.js:5771

Manager.registerPostprocessor.uses ext-all-debug.js:6004

Ext.apply.doProcess ext-all-debug.js:4007

Ext.apply.doProcess ext-all-debug.js:4008

Ext.apply.process ext-all-debug.js:3995

Ext.Class.ExtClass ext-all-debug.js:3911

Ext.ClassManager.create ext-all-debug.js:4676

Ext.apply.define ext-all-debug.js:5095

(anonymous function) Ajax.js:1 //My extended Ajax singleton

Here is how I try to call it

var changes = e.record.getChanges();

if (e.record.get('id'))

changes.id = e.record.get('id');

APP.ux.Ajax.request({

url: '/admin/user/save/',

params: changes,

scope: this

});

UPDATE

That makes sense, I can't believe overlooked that, but I still get the same read property 'isInstance' of undefined error above. Here is how it looks now

And here is the simple class (Updated)

Ext.define('APP.ux.Ajax', {

extend: 'Ext.data.Connection',

requires: [

'APP.ux.Msg'

],

singleton : true,

autoAbort : false,

request: function(config) {

var cfg = config;

Ext.apply(cfg, {

success: function(form, action) {

APP.ux.Msg.alert('Success', action.result.msg);

//TODO: Add more logic here

},

failure: function(form, action) {

switch (action.failureType) {

case Ext.form.action.Action.CLIENT_INVALID:

APP.ux.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');

break;

case Ext.form.action.Action.CONNECT_FAILURE:

APP.ux.Msg.alert('Failure', 'Ajax communication failed');

break;

case Ext.form.action.Action.SERVER_INVALID:

APP.ux.Msg.alert('Failure', action.result.msg);

break;

}

}

});

this.callParent(cfg);

}

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值