這裏是我的店鋪代碼:ExtJs4麻煩與空JSON服務器端上store.sync
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
});
它發送正確的JSON代碼
{
"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
}
但有NULL在php文件響應
var_dump(json_decode($_POST, true));// shows NULL on response
我想我們在這裏討論更新,因爲您讀取的是基於GET的。然後我有'$ _POST'這樣的東西,它必須有一些變量,所以'$ _POST ['taskId']'。查看發送完整請求的螢火蟲或Chrome開發者工具,如果仍無法解決問題,請發佈。 – Izhaki 2012-08-14 00:42:17
在Firebug中,我可以看到商店發送json的網格更新(由於autoSync:true)發送方法是POST,就像您可以在商店的配置中看到的一樣。但在***服務器端*** $ POST數組是*** NULL ***如何以及爲什麼它可以? – Sam 2012-08-14 05:16:38
我希望看到'Request URL'比什麼都重要。它會顯示參數是否未被編碼到url中。無論如何,我複製了你的代碼,所以請看下面的答案。 – Izhaki 2012-08-14 23:03:30