Load the JSON file and assign the data to Captivate variables.
You’ve seen the format of the JSON file – essentially it is a regular data Object with a series of property:value pairs.
Essentially the function gets a request to load data from a path (either a hardcoded .json file path like you created, or the result from a server database request), and then parses the data once it has successfully retrieved it.
We’ll create a function in the cp-loadjson.js file that expects to be sent this file URL, and then make a call to that function in the Captivate frame script, passing the URL.
Initially, we’ll be able to test the success of the data call by tracing the results out into Chrome’s console.
So, let’s get going. Open up cp-loadjson.js in your favourite code editor. You can delete all the code you created in the previous exercise.