0

here is my store code:

 var sql = Ext.create('Ext.data.Store', {
    model: 'SQL',
    groupField: 'project',
    proxy: {
        type:'ajax',
        api: {                
            read: 'data/showText.php', // Called when reading existing records
            update: 'data/saveRollout.php' // Called when updating existing records                
        },
        actionMethods: {               
            read   : 'GET',
            update : 'POST'               
        },         
        reader: {
            type: 'json',
            root: 'data'
        },
        writer: {
            type: 'json'
        }
    },
    autoSync: true,
    autoLoad: true
});

It sends right json code

{
   "projectId":102,
   "project":"2G Rollout and Performance",
   "taskId":123,
   "description":"2)Capacity Sites Delta",
   "january":123,
   "february":0,
   "march":0,
   "april":0,
   "may":0,
   "june":0,
   "july":0,
   "august":0,
   "september":0,
   "october":0,
   "november":0,
   "december":0,
   "id":null
}

But there is NULL on response in php file

var_dump(json_decode($_POST, true));// shows NULL on response
Izhaki
  • 23,372
  • 9
  • 69
  • 107
Samir Maksimov
  • 105
  • 1
  • 2
  • 9
  • I take we are talking about updates here, as you reads are GET based. Then I'm there's such thing as `$_POST`, there must be some variable in it, so `$_POST['taskId']`. Look at firebug or chrome developer tools for the full request being sent, and if you still can't work it out, please post it. – Izhaki Aug 14 '12 at 00:42
  • In Firebug I can see that store send json on grid update(because of autoSync: true) sending method is POST like you can see in configuration of store. But on ***server side*** $POST array is ***NULL*** How and why it can be? – Samir Maksimov Aug 14 '12 at 05:16
  • I was hoping to see the `Request URL` more than anything. It would show whether or not parameters are not encoded to the url. Anyhow, I replicated your code, so see answer below. – Izhaki Aug 14 '12 at 23:03

2 Answers2

1

You are actually sending your data to the server via the request body, not via the url.

Using:

$iRequestBody = file_get_contents('php://input');

Will work.

See similar issue and some (additional) excellent answers.

Community
  • 1
  • 1
Izhaki
  • 23,372
  • 9
  • 69
  • 107
0

Have you tried taking out:

writer: {
    type: 'json'
}

To see if it handles regular text sent to the server, maybe your server is not handling the JSON encoding well.

Reimius
  • 5,694
  • 5
  • 24
  • 42