2012-07-01 49 views
1

這是我的Store類。我正在嘗試完成POST請求。這是我的代碼; 一切工作正常,我也從服務器響應,當我從Firebug檢查它。但唯一的問題是,當我在Firefox檢查Params tab我看到_dc 1341141752113,當我在Firebug檢查Post tab我看到從商店發送POST請求

limit 25 
page 1 
start 0 

1)這些都是一些pamaters這我沒有通過我的代碼。爲什麼我得到這些?

Ext.define('Pro.store.Animal',{ 
    extend:'Ext.data.Store', 
    model:'Pro.model.Animal', 

    proxy: { 
     actionMethods : { 

      read : 'POST' 
     }, 
     type: 'ajax', 
     url : '/projectmy/animal.php' 

    } 

    }); 

2)如果我想參數傳遞到PHP文件,我應該如何修改我的代碼,通過參數?

+0

你可以讓你的2的任何信息)?我有同樣的問題。我無法將任何參數傳遞給PHP腳本。 –

+0

看看我的答案,我已經添加了商店的代碼。它應該幫助你。 (我假設你的PHP腳本沒有問題) – Illep

回答

2
Ext.define('App.store.StoreName', { 
    extend: 'Ext.data.Store', 

    requires: [ 
     'App.model.StoreName' 
    ], 

    constructor: function(cfg) { 
     var me = this; 
     cfg = cfg || {}; 
     me.callParent([Ext.apply({ 
      storeId: 'stid', 
      model: 'App.model.MyModel', 
      proxy: { 
       type: 'ajax', 
       actionMethods: 'POST', 
       api: { 
        read: '../myreadPhp.php', 

       }, 
       reader: { 
        type: 'json' 
       } 
      }, 
      listeners: { 
       beforeload: { 
        fn: me.onArraystoreBeforeLoad, 
        scope: me 
       } 
      } 
     }, cfg)]); 
    }, 

    onArraystoreBeforeLoad: function(store, operation, options) { 
     this.proxy.extraParams.yournameparameter = "pass some name here"; 
     this.proxy.extraParams.yourageparamete = "pass your age here"; 
    } 

}); 

myreadPhp.php將期待參數yournameparameteryourageparamete

5

這些參數是默認值。如果您使用分頁工具欄或其他控件瀏覽數據,則需要它們。 有關其他參數,您可以使用extraParams in your proxy

+0

添加到此答案中,_dc是自動添加的「cache-busting」參數,以確保每次都調用唯一的url。請參閱Ext.data.proxy.Server類中的noCache參數。 –