DrunkenBeard
9 Sep 2011, 7:23 AM
Hi there,
I'm trying to make a list fetch its content from a database. Basically, I have a page named "JSONData.php" that when called with the appropriate parameters returns a valid JSON object. For the sake of troubleshooting I made that page always return the same JSON object : {"data":[{"lastname":"a", "firstname":"b"}, {"lastname":"c", "firstname":"d"}]}. Now to be completely sure that the problem wasn't with the returned JSON string I also made an Ajax request using Ext and verified that the page actually returned the string as expected.
The list code is pretty basic :
{ xtype: 'list',
store: listStore,
itemTpl: '<div class="contact"><strong>{firstname}</strong> {lastname}</div>'
}
Now here's the part that most likely isn't quite right :
var listStore = new Ext.data.Store({
autoLoad: true,
model: 'Contact',
proxy: {
type: 'ajax',
url : 'app/remote/JSONData.php',
actionMethods: {
read: 'POST'
}
},
reader: new Ext.data.JsonReader ({
root:'data',
})
});
Any idea why does this return a "Unable to parse JSON returned by Server" exception ?
Thanks :)
PS : I also make sure to register the "Contact" model using Ext.regModel.
PS 2 : The full exception actually reads : "Uncaught Ext.data.JsonReader.getResponseData: Unable to parse JSON returned by Server."
I'm trying to make a list fetch its content from a database. Basically, I have a page named "JSONData.php" that when called with the appropriate parameters returns a valid JSON object. For the sake of troubleshooting I made that page always return the same JSON object : {"data":[{"lastname":"a", "firstname":"b"}, {"lastname":"c", "firstname":"d"}]}. Now to be completely sure that the problem wasn't with the returned JSON string I also made an Ajax request using Ext and verified that the page actually returned the string as expected.
The list code is pretty basic :
{ xtype: 'list',
store: listStore,
itemTpl: '<div class="contact"><strong>{firstname}</strong> {lastname}</div>'
}
Now here's the part that most likely isn't quite right :
var listStore = new Ext.data.Store({
autoLoad: true,
model: 'Contact',
proxy: {
type: 'ajax',
url : 'app/remote/JSONData.php',
actionMethods: {
read: 'POST'
}
},
reader: new Ext.data.JsonReader ({
root:'data',
})
});
Any idea why does this return a "Unable to parse JSON returned by Server" exception ?
Thanks :)
PS : I also make sure to register the "Contact" model using Ext.regModel.
PS 2 : The full exception actually reads : "Uncaught Ext.data.JsonReader.getResponseData: Unable to parse JSON returned by Server."