Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS 4 - Problems with JsonStore + Post Request

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.

like image 640
M00ly Avatar asked Sep 06 '11 08:09

M00ly


1 Answers

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'
}
like image 101
Ivan Avatar answered Oct 03 '22 16:10

Ivan