尝试捕获 302 状态 EXT js
我是 EXTJS 的新手,有一个问题, 这是我的商店
someStore = new Ext.data.JsonStore({
root: 'results',
proxy: new My.HttpProxy({
url: '/cityList',
method: 'POST'
}),
fields: ['id','name']
});
,当我获得 ID 时,我需要按 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 有一个特定的回调?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来你过于复杂了:
It seems like you overcomplicated: