I’m trying to use Sencha Touch script tag proxy so that I can consume a JSON file on a remote website, however I am seeing parse errors in the Safari Console even though I have validated the JSON file is correct.
My Model is this:
Ext.regModel('NoteNewsModel', {
idProperty: 'id',
fields: [
{ name: 'id', type: 'int' },
{ name: 'title', type: 'string' },
{ name: 'description', type: 'string' }
// { name: 'icon', type: 'string' }
]
});
My Store code is this:
Ext.regStore('NotesNewsStore', {
model: 'NoteNewsModel',
proxy: {
type: 'scripttag',
url: 'myjsonurl',
reader: new Ext.data.JsonReader ({
type: 'json',
root: 'entries'
})
},
autoLoad: true
});
Here is part of the JSON file on the remote server:
{
"title":"json news",
"link":"https://myurl.com/json-news.html",
"description":"",
"language":"en",
"copyright":"my domain",
"ttl":"120",
"entries":[
{
"title":"SmarterMail Upgrade",
"link":"https://mydomain.com/122.html",
"date":"1316414335",
"guid":"https://mydomain.com/122.html",
"author":"flank plank",
"description":"test entry",
"introtext":"testing the intro text."
}
]
}
Finally the error I am seeing in Safari console shows below the first line
“title”:json news”,
data.json:2SyntaxError: Parse error
Any help on this would be appreciated I have been scratching my head for a few hours on this one now.
Thanks Aaron
After much trial and error, I found that this was not working due to my JSON file not being formatted correctly.
I followed this example: http://www.sencha.com/learn/legacy/Tutorial:Creating_JSON_Data_in_PHP
And with this code on my local server it now works fine.