title: Javascript - Storing high scores for my game in a JSON file
body: <p>I working on a game built using Javascript and HTML5 canvas. Almost everything is done except that I'm not able to deploy some kind of functionality that'll allow me to store high scores.</p>
  
  <p>Since the game is just an HTML page that includes a lot of Javascript files i.e. no database, my plan of action was to store all the high scores in a hash table like - </p>
  
  <pre><code>{
    "Bruce":100,
    "Alexis":84,
    "Megan":69,
    "Carlos":52
  }
  </code></pre>
  
  <p>and then store that as a JSON file. Each time a user loads up the game, the JSON file will be parsed and the high scores could be displayed by iterating over the hash table.</p>
  
  <p>But I can't get this to work. Here are the problems I'm running into - </p>
  
  <ol>
  <li><p>jQuery's getJSON method won't allow me to get a file that is stored locally. So I'm storing the file on my Github and passing the URL as an argument. Is that the right fix? I'm ultimately planning to host this game using Github pages so I thought I'll have to change the URL a little bit when I deploy to production.</p></li>
  <li><p>After that, it threw this error at me...</p>
  
  <p>No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.</p>
  
  <p>I looked around and installing a Allow-Control-Allow-Origin extension on Chrome fixed it. Again, is that the right fix?</p></li>
  <li><p>And that brings us to where I'm right now. This is how my method call looks like - </p></li>
  </ol>
  
  <p>this</p>
  
  <pre><code>$.getJSON('https://github.com/.../scores.json', function (data) {
    console.log(data);
  }).fail(function( jqxhr, textStatus, error ) {
    var err = textStatus + ", " + error;
    console.log( "Request Failed: " + err );
  });
  </code></pre>
  
  <p>I'm getting this error on the last line - </p>
  
  <p>Request Failed: parsererror, SyntaxError: Unexpected token &lt;</p>
  
  <p>Also, please lemme know if I'm following the right approach to the problem that I'm trying to solve...</p>