Thanks Kyle -- that's exactly what I needed for the current circumstance. It might not be the best, but it looks like the simplest by a long shot.
Thanks to Conal too.
I'm so glad to have a community of folks who can help spare us from hours of anguish and frustration!
Ken
________________________________________
From: Code for Libraries [[log in to unmask]] on behalf of Kyle Banerjee [[log in to unmask]]
Sent: Wednesday, April 06, 2016 9:45 PM
To: [log in to unmask]
Subject: Re: [CODE4LIB] including data from static JSON file in Javascript
If all you want to do is load external json as a string, you can do it
using syntax almost identical to what you suggest. Just change your
data.json file so the content is
var data = ' [include your json here, be sure to escape things properly]';
Then just load this file before your external script e.g.:
<script language="javascript" src="data.json"></script>
<script language="javascript" src="external_script.js"></script>
Within external_script.js, you can reference the data variable just as you
would have had it been defined in external_script.js.
Depending on what you're doing with your json, it may or may not be a good
approach, but it will work.
kyle
|