PDA

View Full Version : Could not get data from ajax



ingkiang
20 Sep 2012, 1:57 AM
im new to ext js, im having problem getting data from ajax to php
i check with firebug in the post tab, there is data with json format but its not available in the php global variables like $_POST, $_REQUEST and $_GET

Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model : 'AM.model.User',
autoLoad: true,

proxy: {
type: 'ajax',
api: {
read: 'data/users.php',
update: 'data/updateUser.php'
},
reader: {
type: 'json',
root: 'users',
successProperty: 'success'
}
}

});

redraid
20 Sep 2012, 2:28 AM
php dont parse json post request so you need to get raw post data:


if ($json = @file_get_contents('php://input'))
{
$json_post = json_decode($json);
}
else
{
$json_post = array();
}

iplanit
20 Sep 2012, 7:27 AM
Also, you have to be sure that you use POST PUT GET properly.

redraid
21 Sep 2012, 1:38 AM
ajax proxy default api methods:
create: POST
read: GET
update: POST
destroy: POST