shaleth
10 Jun 2013, 1:30 PM
I'm in the very early stages of developing an app. I'm using a store that calls a restful web services API, which I'm also writing... The issue I'm having is this - when I send a single record, brackets seem to be missing from the JSON that is sent back to the php code. The root on the model is "ERRORLOGS"
For example:
logStore.add(
Ext.create('Tim3.model.Log', {
"LOGIN": "shaleth",
"PROC_NAME": "MyProc",
"ERR_MSG": "logging test"
})
);
logStore.sync({
success: function(){ console.log('success'); },
failure: function(){ console.log('failure'); },
scope: this
});
sends:
{"ERRORLOGS":{"LOGIN":"shaleth","PROC_NAME":"MyProc","ERR_MSG":"logging test"}}
When I add a second record to the store and then sync, it works correctly:
logStore.add(
Ext.create('Tim3.model.Log', {
"LOGIN": "shaleth",
"PROC_NAME": "MyProc",
"ERR_MSG": "logging test"
})
);
logStore.add(
Ext.create('Tim3.model.Log', {
"LOGIN": "shaleth",
"PROC_NAME": "MyProc",
"ERR_MSG": "another logging test"
})
);
logStore.sync({
success: function(){ console.log('success'); },
failure: function(){ console.log('failure'); },
scope: this
});
returns:
{"ERRORLOGS":[{"LOGIN":"shaleth","PROC_NAME":"MyProc","ERR_MSG":"logging test"},{"LOGIN":"shaleth","PROC_NAME":"MyProc","ERR_MSG":"another logging test"}]}
Note the brackets starting after the first colon - those are missing in the single record example. PHP barks on the single record example - json_decode handles the two situations very differently. What am I missing here? Is this expected behavior?
For example:
logStore.add(
Ext.create('Tim3.model.Log', {
"LOGIN": "shaleth",
"PROC_NAME": "MyProc",
"ERR_MSG": "logging test"
})
);
logStore.sync({
success: function(){ console.log('success'); },
failure: function(){ console.log('failure'); },
scope: this
});
sends:
{"ERRORLOGS":{"LOGIN":"shaleth","PROC_NAME":"MyProc","ERR_MSG":"logging test"}}
When I add a second record to the store and then sync, it works correctly:
logStore.add(
Ext.create('Tim3.model.Log', {
"LOGIN": "shaleth",
"PROC_NAME": "MyProc",
"ERR_MSG": "logging test"
})
);
logStore.add(
Ext.create('Tim3.model.Log', {
"LOGIN": "shaleth",
"PROC_NAME": "MyProc",
"ERR_MSG": "another logging test"
})
);
logStore.sync({
success: function(){ console.log('success'); },
failure: function(){ console.log('failure'); },
scope: this
});
returns:
{"ERRORLOGS":[{"LOGIN":"shaleth","PROC_NAME":"MyProc","ERR_MSG":"logging test"},{"LOGIN":"shaleth","PROC_NAME":"MyProc","ERR_MSG":"another logging test"}]}
Note the brackets starting after the first colon - those are missing in the single record example. PHP barks on the single record example - json_decode handles the two situations very differently. What am I missing here? Is this expected behavior?