-
28 Feb 2012 1:33 PM #1
Answered: JSON load to DataView doesn't work
Answered: JSON load to DataView doesn't work
Any mistakes in the following code? I've been trying again and again but my JSON load doesn't work...I just see "Loading..." for several seconds then just a blank screen. I've tried loading via AJAX too, but that doesn't show the "Loading..." screen. Thanks in advance for the assistance.
Sample of my JSON data:
Code:{"households":[{"HHName":"Jim Smith Household"}])Code:Ext.regModel('Household', { fields: [ {name: 'HHName', type: 'string'} ] }); var store = Ext.create('Ext.data.Store', { model : 'Household', proxy: { type: 'jsonp', url: 'get_households.php', reader: { type : 'json', root: 'households' } }, autoLoad: true }); var list = Ext.create('Ext.DataView', { store: store, itemTpl: '<p>household name is {HHName} </p>' });
-
Best Answer Posted by mitchellsimoens
You are using JsonP so is the response valid for JsonP?
-
28 Feb 2012 3:48 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
- Answers
- 3113
Ext.regModel is not valid in ST2 and root config in the reader is now rootProperty:
Code:Ext.define('Household', { extend : 'Ext.data.Model', config : { fields : [ { name : 'HHName', type : 'string' } ] } }); var store = Ext.create('Ext.data.Store', { model : 'Household', autoLoad : true, proxy : { type : 'jsonp', url : 'data/php.php', reader : { type : 'json', rootProperty : 'households' } } }); var list = Ext.create('Ext.dataview.DataView', { fullscreen : true, store : store, itemTpl : '<p>household name is {HHName} </p>' });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
28 Feb 2012 6:42 PM #3
Still having trouble
Still having trouble
Thanks for the reply, did not know that about ST2. I tried the new code but I'm still having an issue. I get the "Loading..." spinner for several seconds (15 or so) then a blank screen.
The PHP file is in the same directory as my custom Sencha app.js. I've tried the filename "get_households.php" as well as the full path (http://mywebsite.com/get_households.php) to no avail.
Any other ideas?
-
28 Feb 2012 6:47 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
- Answers
- 3113
You are using JsonP so is the response valid for JsonP?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
28 Feb 2012 6:55 PM #5
It was not, after all, I was sending just plain JSON. Thanks, I've now learned the difference between JSON and JSONP...changed the type property to 'ajax' and I'm off and running.
Thanks again for your help!


Reply With Quote