我是EXTJS的新手,有问题, 这是我的商店
someStore = new Ext.data.JsonStore({
root: 'results',
proxy: new My.HttpProxy({
url: '/cityList',
method: 'POST'
}),
fields: ['id','name']
});
当我得到并且我需要通过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});
}
}
};
以及
My.HttpProxy = Ext.extend( Ext.data.HttpProxy, {
doRequest : function(action, rs, params, reader, cb, scope, arg) {
...
if(this.useAjax){
Ext.applyIf(o, this.conn);
if (this.activeRequest[action]) {
}
this.activeRequest[action] = **My.Ajax.proxyRequest(o);**
问题是我得到了我需要的数据的响应,但是商店没有重新加载数据..可能是JsonStore有一个特定的回调?
答案 0 :(得分:2)
看起来你太复杂了:
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' }
} );