diff -r 322d0feea350 -r 89ef5ed3c48b src/cm/media/js/lib/yui/yui_3.10.3/docs/datasource/datasource-get.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.10.3/docs/datasource/datasource-get.html Tue Jul 16 14:29:46 2013 +0200 @@ -0,0 +1,287 @@ + + + + + Example: DataSource.Get + + + + + + + + + + +
+
+

+
+ + +

Example: DataSource.Get

+
+
+
+
+ +
+

DataSource.Get uses the Get Utility to retrieve data, even cross-domain resources, via a dynamically created script node. A DataSchema plugin is used to normalize incoming data into a known format for consistency of usage by other components. Please note that your data resource must support a callback mechanism, which is a function wrapper around the returned data. The name of the callback function is passed to the resource via a query string parameter defined by the DataSource.Get attribute scriptCallbackParam.

+
+ +
+
+

JSON

+
Data
+
+{
+    "query":{
+        "count":"10",
+        "created":"2011-06-15T04:36:13Z",
+        "lang":"en-US",
+        "results":{
+            "event":[
+                {
+                 "id": "6826736",
+                 "name": "PGA Fall Expo 2011",
+                 "start_date": "2011-08-01",
+                 "venue_name": "The Venetian Congress and Sands Expo Convention Center",
+                 ...
+                },
+                {
+                 "id": "7228592",
+                 "name": "NAHC 30th Annual Meeting & Exposition",
+                 "start_date": "2011-10-01",
+                 "venue_name": "Mandalay Bay Resort",
+                 ...
+                },
+                {
+                 "id": "7238009",
+                 "name": "Water and Society 2011-First International Conference on Water and Society",
+                 "start_date": "2011-12-05",
+                 "venue_name": "Richard Tam Alumni Center",
+                 ...
+                },
+                ...
+            ]
+        }
+    }
+}
+    
+ +
Schema
+
+{
+    resultListLocator: "query.results.event",
+    resultFields: ["name"]
+}
+    
+ +
Normalized data
+ +
+
+ + + + +
+ +

Use a DataSourceJSONSchema plugin to parse the data against a schema that you provide:

+ +
YUI().use("datasource-get", "datasource-jsonschema", function(Y) {
+    var myDataSource = new Y.DataSource.Get({
+            source: "http://query.yahooapis.com/v1/public/yql?format=json&"
+        });
+
+    myDataSource.plug(Y.Plugin.DataSourceJSONSchema, {
+        schema: {
+            resultListLocator: "query.results.result",
+            resultFields: ["title"]
+        }
+    });
+
+    myDataSource.sendRequest({
+        request: "q=select%20*%20from%20upcoming.events.bestinplace...",
+        callback: {
+            success: function (e) { /* output to screen */ },
+            failure: function (e) { /* output to screen */ }
+        }
+    });
+
+});
+ + +
+
+
+ +
+ +
+
+
+ + + + + + + + + + +