【问题标题】:ExtJS 4 - Problems with JsonStore + Post RequestExtJS 4 - JsonStore + Post 请求的问题
【发布时间】:2011-11-11 03:09:00
【问题描述】:

我正在尝试使用 POST 请求调用 API。但我的 Chrome Inspector 在网络选项卡中显示method='GET'...

这是我的代码:

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

所以O想用method='POST'和参数operation = showall调用API

Google Inspector 在网络标签中向我显示以下信息:

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

为什么是 GET 请求?

为什么会有limit、start、dc等参数?

我已经尝试了 1000 个教程,并在谷歌上搜索了一整晚。

【问题讨论】:

标签: javascript ajax json extjs extjs4


【解决方案1】:

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

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

【讨论】:

  • 但是如何设置请求正文??
猜你喜欢
  • 2014-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多