For example, you might want to use the JSON code in a file called object-02.js. The file might be located in a folder called data in the site’s root folder:
data/object-02.js
You could also specify a URL to the HTML file, as follows:
http://www.somesite.com/somefolder/object-02.js
<script type="text/javascript"> var datasetName = new Spry.Data.JSONDataSet("sourcefile", {path:"datapath"}); </script>
A completed statement might look as follows:
var ds1 = new Spry.Data.HTMLDataSet("data/object-02.js", {path:"batters.batter"});
The statement creates a new data set called ds1 that retrieves data from the batters.batter property in the specified JavaScript file.
You can also specify a URL as the source of the data, as follows:
var dsSpecials = new Spry.Data.JSONDataSet("http://www.somesite.com/somefolder/object-02.js", {path:"batters.batter"});
The completed example code might look as follows:
<head> ... <script type="text/javascript" src="includes/SpryJSONDataSet.js"></script> <script type="text/javascript" src="includes/SpryData.js"></script> <script type="text/javascript"> var ds1 = new Spry.Data.JSONDataSet("data/object-02.js", {path:"batters.batter"}); </script> ... </head>
After you’ve created the data set, create a dynamic region so that you can display the data.