2011-02-08 16 views
5

Soy nuevo a ExtJs, y tiene un problema, esta es mi tiendatratando de atrapar estado 302 Ext JS

someStore = new Ext.data.JsonStore({ 

    root: 'results', 
    proxy: new My.HttpProxy({ 
     url: '/cityList', 
     method: 'POST' 
    }), 
    fields: ['id','name'] 
}); 

cuando llegue y Id necesito para recargar tienda por id someStore.reload ({params: {someId: someId}});

funciona normaly si uso Ext.data.HttpProxy, pero necesito para atrapar 302 y hacer algo manipulación,

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}); 
     } 
    } 
}; 

y también

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);** 

el problema es que recibo la respuesta con los datos que necesito, pero la tienda no se vuelve a cargar con los datos ... ¿Puede ser que JsonStore tenga una devolución de llamada específica?

Respuesta

2

Parece que overcomplicated:

  • 200 es uno de susscess
  • 302 es una de insuficiencia
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' } 
});