PDA

View Full Version : Cannot find JSON data in POST



nicobarten
31 Jul 2013, 10:39 AM
hi all,

I have this model:



Ext.define('HGG.model.Newsletter',
{
extend: 'Ext.data.Model',
fields: [
'id',
'title',
'author',
'content',
'created_at',
'updated_at',
'visible'
],

proxy:
{
type: 'ajax',
api:
{
//create: 'data/newsletter/create',
create: 'data/index.php', // for testing
read: 'data/newsletter/read',
update: 'data/newsletter/update',
destroy: 'data/newsletter/delete'
},
reader:
{
type: 'json',
root: 'data',
successProperty: 'success'
}
}
});


In my controller i create a new instance of it succesfully, and call the 'save' function. I see in firebug that the POST data in JSON format is sent:

45144

In the php file i immediately do var_dumps of both $_GET and $_POST. However, although the $_GET has the correct values, $_POST is completely empty - no json, nothing!

The only thing i can come up with is that firebug sees the data in the POST in json format, but doesn't have a 'name' for where the data can be stored in the POST (like $_POST['myjson']). Is the data somewhere else stored in PHP, must i set some apache config? I've searched for an hour already, but i'm lost...

Edit: found it, the JSON is set in HTTP PUT. Very weird in an ajax proxy though...

tobiu
31 Jul 2013, 4:28 PM
Hi Nico,

by default the Ajax Proxy uses:


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


and the Rest Proxy (which extends Ajax) uses:


actionMethods: {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy: 'DELETE'
}


Please check your codebase if you have any overrides in place that change those actionMethods, since by default it should use post.

In case there are no changes feel free to open a bugreport.

Best regards
Tobias