I'm new to EXTJS, and have a problem, this is my store
someStore = new Ext.data.JsonStore({
root: 'results',
proxy: new My.HttpProxy({
url: '/cityList',
method: 'POST'
}),
fields: ['id','name']
});
when i get and Id I need to reload store by id someStore.reload({params:{someId:someId}});
it works normaly if I use Ext.data.HttpProxy, but I need to catch 302 and to do something handling it,
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});
}
}
};
and also
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);**
the problem is that I get the response with data I need, but store doesn't reloads with the data.. May be JsonStore has a specific callback?
It seems like you overcomplicated:
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' }
} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With