I am implementing a Proxy.api function in my store but cannot seem to access the parameters once they are passed to the .php files. The store is connected to a form.Panel and when I click "Create" on the form I want the form elements to be sent to a .php file to be stored in a MYSQL database.
Here is the proxy with api configuration:
Code:
var store = Ext.create('Ext.data.Store', {
//connect it to the person model
model: 'User',
autoLoad: true,
autoSync: true,
//set up the proxy to communicate the data
proxy: {
type: 'ajax',
api: {
read: 'u_read.php',
create: 'u_create.php',
update: 'u_update.php',
destroy: 'u_update.php'
},
//create a reader to read from the database to the store
reader: {
type: 'json',
successProperty: 'success',
root: 'data',
messageProperty: 'message'
}
I can see in FireBug that the 'create' command is executed correctly when I click the "CREATE" button in my application, and it correctly POSTs the 'data' json object:
Capture.PNG
but in the .php file I cannot access the 'data' json object or its contents.
This is what I have in u_create.php:
Code:
<?php
//get passed parameters
$data = $_POST[data];
$email = $data['email'];
$first = $data['first'];
$last = $data['last'];
$response = array();
$response['success'] = true;
$response['message'] = "Created User";
$response['data'] = array(
'first' => $first,
'last' => $last,
'email' => $email);
return json_encode($response);
?>
but the application doesn't return the $response json packet - it returns '0' and a 'result is undefined' error
How can I access the POSTed arguments sent to my .php file from the proxy.api?
Thanks in advance!