-
16 Aug 2012 1:54 PM #1
Answered: Problem retrieving JSON from Yahoo Pipes
Answered: Problem retrieving JSON from Yahoo Pipes
Hi i have a very similar problem to http://www.sencha.com/forum/showthre...P.request-does and after a lot of searching found this thread. I am tryin to access using a proxy to a Yahoo Pipes Json output. My code is as follow
Code:Ext.Viewport.add(Ext.create('Ext.DataView', { fullscreen: true, store: { autoLoad: true, fields: [ 'fuente','texto'], proxy: { type: 'jsonp', url: 'http://pipes.yahoo.com/pipes/pipe.run?_id=739242db9d5c22158ccc6ef85b588b0d&_render=json', reader: { type: 'json', encodeRequest: true, rootProperty: 'value.items' } } }, itemTpl: '<img src="{fuente}" /><h2>{texto}</h2>' }));
It keeps giving me Uncaught SyntaxError: Unexpected token : in pipe.run 1
I have tried cutting the json and creating an object in the console and it works well. I also change the url in order to fetch data from twitter api and also work. Seems that the problem is about pipes.
Any help would be very appreciated. Thanks in advance!!!!
-
Best Answer Posted by mitchellsimoens
There is a difference between JSONP and JSON... JSONP takes JSON and wraps it in a callback method to be executed but the response you are getting is just JSON so you will get an error.
-
18 Aug 2012 9:03 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
There is a difference between JSONP and JSON... JSONP takes JSON and wraps it in a callback method to be executed but the response you are getting is just JSON so you will get an error.
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.
-
20 Aug 2012 7:48 AM #3
Thank you very much mitchell. With your help I solved the problem. The thing is that by specifying that my store uses jsonp, Sencha automatically added a callback to my url as I was able to see through Chrome. So it looks like http://pipes.yahoo.com/pipes/pipe.run?...&callback=Ext.data.JsonP.callback1
But pipes expects its jsonp call to have as name _callback(with an uderscore before the name) as specified here http://pipes.yahoo.com/pipes/docs?do...leshooting#q12 so I added the parameter callbackKey: '_callback' to the proxy definition and all worked ok!!!! Thank you very much again
-
15 Sep 2012 11:11 AM #4
With the callback key set to '_callback', its working fine. Im having trouble mapping it in my jsonreader. The structure I get from yahoo pipes is
Setting the jsonProperty to 'value.items.item' isn't doing it. Im guessing because the data is nested in arrays...How did you get it to work?Code:{ value: { items:[{ items:[{ ... }] }] } }rafael
-
15 Sep 2012 2:28 PM #5
I do not have a second nested item. My structure is like
so I put rootProperty: 'value.items' an it works fine. In your case I guess you should set the yours to rootProperty: 'value.items.items'Code:{ value: { items:[{ DATA }] } }


Reply With Quote