Importing Data from JSON file to Store
I have begun developing an app where I use Sencha Touch for the frontend design and java to query the database on the backend. However, I am having trouble integrating the two together. I tried returning the data from a java query into a .json file in json format and then loading that into my app through a store but it doesn't seem to be working. I get the error in the Chrome console as shown below.
OPTIONS localhost:8080/ProficyAppData/WebContent/app/store/info.json?_dc=1342618907990&page=1&start=0&limit=25 Resource failed to load
I have my project contained in an eclipse Java Web Project so that I could easily utilize the localhost server. I am unsure as to why the json data is not loading into the store.
Store:
Ext.define('MyApp.store.Questions', {
extend: 'Ext.data.Store',
config: {
autoLoad: true,
model: 'MyApp.model.Question',
proxy: {
type: 'ajax',
url: 'localhost:8080/ProficyAppData/WebContent/app/store/info.json',
reader: 'json'
},
listeners: {
load: function() {
console.log(this);
}
},
}
});
Model:
Ext.define('MyApp.model.Question', {
extend: 'Ext.data.Model',
config: {
fields: ['id', 'criteria', 'description', 'questionName', 'type']
}
});
info.json:
[
{
"id": 1,
"criteria": "no criteria yet",
"description": "no description yet",
"questionName": "no question yet",
"type": "n/a"
},
{
"id": 2,
"criteria": "no criteria yet",
"description": "no description yet",
"questionName": "no question yet",
"type": "n/a"
},
{
"id": 3,
"criteria": "no criteria yet",
"description": "no description yet",
"questionName": "no question yet",
"type": "n/a"
},
{
"id": 4,
"criteria": "no criteria yet",
"description": "no description yet",
"questionName": "no question yet",
"type": "n/a"
},
{
"id": 5,
"criteria": "no criteria yet",
"description": "no description yet",
"questionName": "no question yet",
"type": "n/a"
},
{
"id": 6,
"criteria": "no criteria yet",
"description": "no description yet",
"questionName": "no question yet",
"type": "n/a"
}
]
[1]: https://i.stack.imgur.com/3zxuD.png