72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly<style scoped>
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly/* custom styles for this example */
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly#demo .output {margin-bottom:1em; padding:10px; border:1px solid #D9D9D9;}
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly<div class="intro">
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly <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>
819e90d415ed17d59af3a247b2ad9d6feb0c21b5Luke Smith<div class="example yui3-skin-sam">
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly {{>datasource-get-source}}
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly<p>Use a DataSourceJSONSchema plugin to parse the data against a schema that you provide:</p>
72378c4b11f0468874fbad14749246d2ae564474Jenny DonnellyYUI().use("datasource-get", "datasource-jsonschema", function(Y) {
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly var myDataSource = new Y.DataSource.Get({
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly source: "http://query.yahooapis.com/v1/public/yql?format=json&"
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly myDataSource.plug(Y.Plugin.DataSourceJSONSchema, {
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly resultListLocator: "query.results.result",
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly resultFields: ["title"]
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly request: "q=select%20*%20from%20upcoming.events.bestinplace...",
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly success: function (e) { /* output to screen */ },
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly failure: function (e) { /* output to screen */ }