I'm trying to learn JSON/JavaScript as I'd like to use it over PHP/SQL.
I was going to do this with TEMPOJS because it seems like that might be the easiest way to start off?
I'm getting hung up, however. I can make everything work if I include the JSON directly in my scripting. However, for the project I am working on, I need to use an external JSON feed and I can't figure out how to make my script pull in the external feed. Here is what I've got to start off:
In the header tags:
<!-- TEMPO JS LOADIN -->
<script type="text/javascript" src="tempo/tempo.min.js"></script>
In the content area, where I'm wanting data to appear:
<ul id="users">
<li data-template>
{{firstName}} {{lastName}}
</li>
<li data-template-fallback>Must have JavaScript active.</li>
</ul>
Right before </body>:
<!-- TEMPOJS SCRIPT -->
<script>
var data = {
people: [
{ 'firstName': 'Clark', 'lastName': 'Kent' },
{ 'firstName': 'Bruce', 'lastName': 'Wayne' },
{ 'firstName': 'Peter', 'lastName': 'Parker' }
]
}
Tempo.prepare("users").render(data.people);
</script>
In the above </body> script, I'm wanting to change the "var data =" portion so that it would pull in data from a JSON script. For testing, I have that script in the same directory as data.json. Eventually, however, it will be hosted on another server.