title: How to store data from a local javascript file into an array
body: <p>This is probably pretty easy but I can't seem to find the answer anywhere.  </p>
  
  <p>I have a local javascript file with JSON data (data.js) that I would like to call from another js file (build.js) where I will name the array.  How would you do this?</p>
  
  <p><strong>data.js</strong></p>
  
  <pre><code>[
    {"name": "bob"},
    {"name": "sally"},
    {"name": "jane"}
  ]
  </code></pre>
  
  <p><strong>build.js</strong>  --> I've tried storing the data in a string and even that is not working...</p>
  
  <pre><code>var namesArray;
  
  function build(){
      $.ajax({
          url: 'data.js',
          type: 'get',
          success: function(data) {
              namesArray = String(data); // this part doesn't work!!
          }
      });
  }
  
  $(document).ready(function(){
      build();
  });
  </code></pre>
  
  <p>Ultimately what I want to achieve is to be able to call namesArray[0].name and be able to output "bob"... but I definitely do not want to name the array from within data.js.  Help! Thanks!</p>