2011-09-06 97 views
5

我试图用POST请求调用API。但我的Chrome检查显示我method='GET'在网络标签...ExtJS 4 - JsonStore + Post请求的问题

这里是我的代码:

Ext.define('TestItem', { 
     extend: 'Ext.data.Model', 
     fields: [ 
      {name: 'id', type: 'int'}, 
      {name: 'name', type: 'string'} 
    ] 
    }); 

    var testStore = Ext.create('Ext.data.JsonStore', { 
     model: 'TestItem', 
     autoLoad: true, 
     proxy: { 
      type: 'ajax', 
      url : '../path_to/api/', 
      method : 'POST', 
      reader: { 
       type: 'json', 
       root: 'data', 
       totalProperty: 'total' 
      } 
     }, 
     baseParams: { 
      operation:'showall' 
     } 
    }); 

所以Ø想打电话与method='POST' API和参数operation = showall

的谷歌督察节目我在网络选项卡中输入以下信息:

GET ../path_to/api/?_dc=1315297478131&page=1&start=0&limit=25 HTTP/1.1 

为什么它是GET请求?

为什么会有限制,启动和直流等参数?

我已经试过1000个教程,并搜索了整个晚上。

+1

可能重复[extjs4店就将此得到的网址参数(http://stackoverflow.com/questions/6925081/extjs4-store-addes-get-params-in-the-url/6926857#6926857 ) –

回答

17

在extjs4方法:POST不起作用。在extjs4中,任何读取都是通过GET发送的,任何写入(POST,PUT,DELETE)都是通过POST发送的。要覆盖这个请参阅actionMethods。

type: 'ajax', 
actionMethods: { 
    create : 'POST', 
    read : 'POST', 
    update : 'POST', 
    destroy: 'POST' 
} 
+0

是的,非常感谢! – M00ly

+0

但我该如何设置请求体? – Isaac

+0

+1为答案。 –