PDA

View Full Version : JsonStore with POST doesn't work?



m00l
6 Sep 2011, 12:43 AM
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.

skirtle
6 Sep 2011, 3:40 AM
Please use CODE tags when you post code (# button on the editor toolbar).

I don't believe method is a valid option for an Ajax proxy. Try:


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

If you're not doing create, update or destroy you can probably leave them out.

_dc is the cache-breaker. It only applies to GET requests.

The other extra parameters you are seeing are the parameters for paging. It's requesting the first page. If you don't want paging then your server should ignore them.

m00l
6 Sep 2011, 3:46 AM
Thank you skirtle, it works!

One more thing for all guys having the same troubles:

I send the parameters with

extraParams: {
operation:'adminshowallgigs'
}

NOT with params : {} or baseParams : {}, they didn't work