| Page 1 of 1 | [ 4 posts ] |
|
Hello,
I have been trying for several days to get DataSource.Get to work. I started off ambitiously and failed - so I slowly refined my prototype to a very simple variation of the example YUI3 DataTable + DataSource.Get + JSON Data and it still does not work. The test code: http://pastie.org/2647743 The dirty details: I downloaded the JSON from query.yahooapis.com to a file called yql.php. I transformed it to a php script that sets a couple of headers and echos the JSON data when called (I removed an apostrophe from a text field to simplify quoting). When I download from my php script using my browser the resulting file is identical to the file retrieved from query.yahooapis.com (with the exception of the removed apostrophe and a timestamp embedded in the JSON). The php script does not interpret any of the query passed to it on the url. These are the headers php sends: Code: header("HTTP/1.1 200 OK"); header('Content-type: application/json; charset=utf-8'); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Pragma: no-cache"); The results: When pointing the "source" to query.yahooapis.com it creates the table including the data. When pointing the "source" to my yql.php it creates the table headers and displays no data. In my server logs I can see the yql.php file is retrieved with HTTP "200" so I believe the file is being found and data is getting to DataSource. I am entirely stumped and would appreciate any suggestions. Regards, Jon |
|
I have noticed references here http://yuilibrary.com/yui/docs/datasource/#get to the server supporting a "script callback parameter". I have no idea what this means. Can anyone tell me how I would check and/or implement this?
Might this be my problem? |
|
Get creates a <script> tag that loads whatever comes from the given URL. Imagine you write that script tag yourself into the <head>. If that URL provides just data, it will be read, evaluated and, since it is not being assigned anywhere, discarded. Basically, imagine you do this:
<script>1</script> That number one will be read, evaluated and discarded. So, the callback parameter is the name of a function that would do something with the data. The data actually gets enclosed in a function call, like this: <script>cbFunc(1)</script> Now, the function cbFunc gets that 1 and may do something with it. The script datasource provides a callback for each call so it gets the data and can do something with it before it gets lost. It generates those callbacks dynamically so your server must use whichever the datasource generated in each call. |
Alberto SantiniYUI Contributor
|
Hello Jon.
The snippet you pasted works correctly: http://jsfiddle.net/R2XYS/ I suggest to double check the server response compared with yql one. YQL returns the response in jsonp format as explained by Satyam. See also "DataSource Get reading json response - very basic": viewtopic.php?f=92&t=8685&p=27874 Hope that helps, Alberto |
| Page 1 of 1 | [ 4 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group