-
5 Jan 2013 5:49 PM #1
Answered: Problems getting my store's proxy config to work
Answered: Problems getting my store's proxy config to work
I'm trying to build a simple rss reader to get a handle on how stores work. I created the shell of the application and set up a list view with an item template, the correct model, and then created a store with inline data to verify it worked (which it did).
I then tried commenting out my inline data in the store and replaced it with a proxy configuration to try to read directly from the rss feed's xml file and I can't get it to work. I'm not sure what I'm missing and really I'm not sure where to check in my browser's dev tools to troubleshoot.
I also tried saving the xml to a file I stored within my project and changed my proxy config to use ajax and pointed it to the local file (you can see those config lines commented out) just to see if there was an error with getting it from the external domain and it still did not work.
Could anyone help point me in the right direction?
Here's my store's code:
Code:Ext.define('DorklyReader.store.Feed',{ extend: 'Ext.data.Store', requires: ['Ext.data.proxy.JsonP', 'Ext.data.reader.Xml'], config:{ model: 'DorklyReader.model.Feed', proxy: { type: 'jsonp', url: 'http://www.dorkly.com/rss', // type: 'ajax', // url: 'store/exampleFeed.xml', reader: { type: 'xml', record: 'items', rootProperty: 'items' }, autoload: true } //The app works when reading from this inline data: // data: [ // // Build with sample data first before building the proxy section. // {guid: '1234', link: 'http://www.google.com', title: 'dog jumps over log', description: 'wow what a dog!'}, // {guid: '5678', link: 'http://www.google.com', title: 'cat sits on hat', description: 'typical cat!!'}, // {guid: '9098', link: 'http://www.google.com', title: 'fish swims!', description: 'who could have seen that coming?!!'}, // ] } });
-
Best Answer Posted by mitchellsimoens
There is no xml proxy, you need to use ajax proxy. If you are wanting to do cross origin requests then the server will need to support CORS which is just a couple headers returned by the server and it will just work. http://enable-cors.org/
-
7 Jan 2013 8:27 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
jsonp proxy will only work with json not xml but requires more than just plain json.
autoload should be autoLoad and on the store not the proxy.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.
-
7 Jan 2013 8:45 AM #3
Ah gotcha.
When I was reading the documentation on proxies: http://docs.sencha.com/touch/2-1/#!/...ta.proxy.Proxy
I misunderstood the line:
thinking that I needed to use JSON-P anytime I wanted to send requests to a different domainJsonP - uses JSON-P to send requests to a server on a different domain
vs
I needed to use JSON-P anytime I wanted to send requests to a different domain using json.
So in the end, in addition to the autoLoad changes, I need to change my proxy type to 'xml' and that should resolve the issue, right?
Also (assuming that is the correct answer), where would I have found that in the documentation? On the doc page for touch's proxies it doesn't list types that deal with external servers other than Json-P (unless I'm missing it).
Thanks for your response!
-
7 Jan 2013 8:48 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
There is no xml proxy, you need to use ajax proxy. If you are wanting to do cross origin requests then the server will need to support CORS which is just a couple headers returned by the server and it will just work. http://enable-cors.org/
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.
-
7 Jan 2013 9:24 AM #5
Cool. Thanks for the help!


Reply With Quote