IO: Cross-Domain JSON Transaction — Retrieving a News Feed from Yahoo! Pipes
+ ++
In the example below, IO is employed to make a cross-domain request to Yahoo! Pipes. The output of the Pipe is an RSS-style feed formatted as JSON. We pass that output to the JSON Utility's parse method for sanitization and then display the contents of the Pipe in a list.
The cross-domain approach obviates the need for a server-side proxy, making it faster. And the use of IO in place of a script node allows us to retrieve the JSON data as a string and execute JSON.parse against it, making it safer to use; a script node would evaluate immediately in the global scope as soon as it was loaded.
-
+
- Content from Yahoo! Pipes feed will display here. +
Implementing a Simple Cross-Domain Request for JSON Data
+ +In this example, we begin with a YUI instance that loads the IO and JSON modules:
+ + +We'll also get a Node reference to the container we'll be using to output the data we retrieve:
+ + + +Next, we configure IO's cross-domain interface for this YUI instance. Flash is the underlying mechansim used here. Be sure to configure the src property to point to your IO.swf file.
The configuration for our specific IO transaction contains a reference to the xdr configuration we created above and specifies that there will not be a need to process the response as XML (we're getting JSON instead):
The final step is to make the request:
+ + + +Full Script
+ +The full script source for this example is as follows:
+ +