I want to access data from a JSON data file to print this to a HTML page by using a javascript file. So far it return 'undefined' and I can't work out why. Heres the code in my files:
template.html:
<!DOCTYPE html>
<html>
  <head>
    <script type ="text/javascript" src="populate.js"></script>
  </head>
  <body>
    <script>
      document.write(me);
    </script>
  <body>
this is my stuff.json file:
[
{"firstname":"James", "lastname":"Davies", "Age":"25"},
{"firstname":"Bill", "lastname":"Jones", "Age":"40"}
]
and this is populate.js
var me;
$.getJSON("stuff.json", function(data) {
  me = data;
});
All these files are in the same directory. I dont know why the me variable isn't being inherited by the javascript file and therefore printed to the html page.
 
    