-
25 Dec 2010 12:45 PM #1
Models, localstorage, store and remote JSON
Models, localstorage, store and remote JSON
Hello,
I have a remote JSON feed that i would like to pass through a model and save in html 5 localstorage using a store. i found some sample code for this in the API Docs.
Now the example here uses a local JSON URL..My JSON feed is remote..Will the above code work if i change the url to http://xyz.com/sample.json ?Code:// Set up a model to use in our Store Ext.regModel('User', { fields: [ {name: 'firstName', type: 'string'}, {name: 'lastName', type: 'string'}, {name: 'age', type: 'int'}, {name: 'eyeColor', type: 'string'} ] }); var myStore = new Ext.data.Store({ model: 'User', proxy: { type: 'ajax', url : '/users.json', reader: { type: 'json', root: 'users' } }, autoLoad: true });
Or does JSONP come into play somewhere..If so how?
Thanks
-
26 Dec 2010 7:49 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
The AjaxProxy will not allow cross-domain calls. You will have to use JSONP or ScriptTagProxy. I believe they work similar with JSONP getting a lot of traction if I may call it that.
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.
-
26 Dec 2010 8:31 AM #3
thanks mitchell but how will i adjust the code above to achieve this cross domain call?
i cant seem to find any example of this anywhere..
thanks
-
26 Dec 2010 8:44 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
Look at the examples. The kitchen sink demo hs a good JSONP EXAMPLE. ScripTagProxy works the same as the other Proxies
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.
-
26 Dec 2010 9:39 AM #5
I have looked at this example but it only shows how to get to the remote JSON Data..not how to move it to localstorage....
-
26 Dec 2010 2:05 PM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
There is another proxy called LocalStorageProxy. This will add files to the HTML5 browser database so you will need an offline Store. Take not of the Store's sync function though.
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.
Similar Threads
-
[FIXED-328] store.loadData + store.sync does not update the index on the localStorage
By axxerion in forum Sencha Touch 1.x: BugsReplies: 4Last Post: 25 Sep 2010, 11:29 AM -
populate comboBox using remote JSON store
By zohaib in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 26 Nov 2009, 6:21 AM -
JSON store does not populate with remote data
By Musical Shore in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 29 Oct 2009, 5:56 AM -
[solved] populate comboBox using remote JSON store
By marcvs in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 14 Sep 2009, 3:59 AM


Reply With Quote