diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/lib/yui/yui_3.0.0b1/examples/io/io-xdr.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.0.0b1/examples/io/io-xdr.html Mon Nov 23 15:14:29 2009 +0100 @@ -0,0 +1,398 @@ + + + + + YUI Library Examples: IO: Cross-Domain JSON Transaction — Retrieving a News Feed from Yahoo! Pipes + + + + + + + + + + + +
+
+
+

+ + YUI 3.x Home - + +

+
+ + +
+ + + +
+
+
+
+

YUI Library Examples: IO: Cross-Domain JSON Transaction — Retrieving a News Feed from Yahoo! Pipes

+
+
+ +

Note: This is YUI 3.x. Looking for YUI 2.x?

+ +
+
+
+
+ +

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:

+ +
+ +
+ +
+
+ + + +
+ +
+

Copyright © 2009 Yahoo! Inc. All rights reserved.

+

Privacy Policy - + Terms of Service - + Copyright Policy - + Job Openings

+
+
+ + + +