最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ExtJS 4 - Problems with JsonStore + Post Request - Stack Overflow

programmeradmin4浏览0评论

I'm trying to call a API with a POST request. But my Chrome Inspector shows me method='GET' in the network tab...

Here's my code:

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

So O want to call the API with method='POST' and the parameter operation = showall

The Google Inspector shows me in the network tab the following information:

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

Why is it a GET request?

Why are there some parameters like limit, start and dc?

I already tried 1000 tutorials and googled the whole night.

I'm trying to call a API with a POST request. But my Chrome Inspector shows me method='GET' in the network tab...

Here's my code:

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

So O want to call the API with method='POST' and the parameter operation = showall

The Google Inspector shows me in the network tab the following information:

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

Why is it a GET request?

Why are there some parameters like limit, start and dc?

I already tried 1000 tutorials and googled the whole night.

Share Improve this question edited Sep 6, 2011 at 10:31 Chau 5,5709 gold badges67 silver badges98 bronze badges asked Sep 6, 2011 at 8:28 M00lyM00ly 631 silver badge3 bronze badges 1
  • 1 possible duplicate extjs4 store addes get params in the url – Molecular Man Commented Sep 6, 2011 at 9:04
Add a ment  | 

1 Answer 1

Reset to default 17

In extjs4 method: POST does not work. In extjs4 any read is send by GET and any write (POST, PUT, DELETE) is send by POST. To override this see actionMethods.

type: 'ajax',
actionMethods: {
    create : 'POST',
    read   : 'POST',
    update : 'POST',
    destroy: 'POST'
}
发布评论

评论列表(0)

  1. 暂无评论