我是EXTJS的新手,有问题,这是我的商店
someStore = new Ext.data.JsonStore({
root: 'results',
proxy: new My.HttpProxy({
url: '/cityList',
method: 'POST'
}),
fields: ['id','name']
});
Run Code Online (Sandbox Code Playgroud)
当我得到并且我需要通过id someStore.reload({params:{someId:someId}})重新加载商店;
如果我使用Ext.data.HttpProxy,它的工作正常,但我需要捕获302并做一些处理它,
My.Ajax = {
proxyRequest: function(o){
this.cbOutSide = o.callback;
o.callback = this.cb;
Ext.Ajax.request(o);
}...
cb: function(options, success, response) {
....
if (response.status == 200) {
var resObj = Ext.util.JSON.decode(response.responseText);
this.cbOutSide(resObj);
}
if (response.status == 302) {
Ext.Msg.show({title: '...',msg: 'Time OUT!',
buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR});
}
}
};
Run Code Online (Sandbox Code Playgroud)
并且
My.HttpProxy = Ext.extend( Ext.data.HttpProxy, {
doRequest : function(action, rs, params, reader, cb, scope, arg) {
Run Code Online (Sandbox Code Playgroud)
....
if(this.useAjax){
Ext.applyIf(o, this.conn);
if (this.activeRequest[action]) {
}
this.activeRequest[action] = **My.Ajax.proxyRequest(o);**
Run Code Online (Sandbox Code Playgroud)
问题是我得到了我需要的数据响应,但是商店没有重新加载数据..可能是JsonStore有一个特定的回调吗?
看来你过于复杂了:
My.Ajax = new Ext.Ajax.request ( {
url: 'foo.php',
success: function ( f, a ) {
// a.response.status == 200, or 304 (not modified)
var resObj = Ext.util.JSON.decode ( response.responseText );
this.cbOutSide ( resObj );
},
failure: function ( f, a ) {
if ( a.response.status == 302) {
Ext.Msg.show ( { title: '...',msg: 'Time OUT!',
buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR } );
}
},
headers: {
'my-header': 'foo'
},
params: { foo: 'bar' }
} );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2221 次 |
| 最近记录: |