2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi<style scoped>
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi/* custom styles for this example */
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd#demo .output {margin-bottom:1em; padding:10px; border:1px solid #D9D9D9;}
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd</style>
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd<div class="intro">
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor <p>DataSource.Get uses the Get Utility to retrieve data, even cross-domain resources, via a dynamically created script node. A <a href="../dataschema/">DataSchema</a> 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`.</p>
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor</div>
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor<div class="example yui3-skin-sam">
6ae232055d4d8a97267517c5e50074c2c819941and {{>datasource-get-source}}
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd</div>
6ae232055d4d8a97267517c5e50074c2c819941and
a78048ccbdb6256da15e6b0e7e95355e480c2301nd<p>Use a DataSourceJSONSchema plugin to parse the data against a schema that you provide:</p>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd```
a78048ccbdb6256da15e6b0e7e95355e480c2301ndYUI().use("datasource-get", "datasource-jsonschema", function(Y) {
f3ec420152ca921e4c1ce77782f51b53f659018dnd var myDataSource = new Y.DataSource.Get({
f3ec420152ca921e4c1ce77782f51b53f659018dnd source: "http://query.yahooapis.com/v1/public/yql?format=json&"
f3ec420152ca921e4c1ce77782f51b53f659018dnd });
f3ec420152ca921e4c1ce77782f51b53f659018dnd
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 */ }
}
});
});
```