title: Load local json file in JQuery
body: <p>Beginner here... I have been trying different methods from answers on this topic
  but none of them seems to work. I see this question has been asked a lot but somehow i still cant find my answer. I want to use a local json file, that is in the same folder as my JavaScript and HTML file so i can make table from the objects in it and be able to add or remove objects from it. As you already know the commented solution doesn't work. Any help? </p>
  
  <p>HTML File:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
  
          &lt;title&gt;Page Title&lt;/title&gt;
          &lt;link rel="stylesheet" type="text/css" media="screen" href="CSS/style.css" /&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
  
              &lt;button id="json"&gt;json&lt;/button&gt;
  
          &lt;!-- &lt;script type="text/javascript" src="books.json"&gt;&lt;/script&gt; --&gt;
          &lt;script src="jquery-3.2.1.js"&gt;&lt;/script&gt;
          &lt;script src="script.js"&gt;&lt;/script&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>JavaScript File:</p>
  
  <pre><code>$(document).ready(function(){
      // var myBooks = JSON.parse(books);
  
  
          $(document).on('click', '#json', function (event) {
  
                  // alert(myBooks[0].author);
                  // alert(myBooks[0].title);
                  // alert(myBooks[1].author);
                  // alert(myBooks[1].title);
          });
  
  });
  </code></pre>
  
  <p>My books.json file</p>
  
  <pre><code>[
      {
          "author": "Margaret Atwood",
          "title": "THE HANDMAID'S TALE"
      },
      {
          "author": "Ursula K. Le Guin",
          "title": "THE DISPOSSESSED"
      },
      {
          "author": "Mary Shelley",
          "title": "FRANKENSTEIN"
      },
      {
          "author": "Ursula K. Le Guin",
          "title": "THE LEFT HAND OF DARKNESS"
      },
      {
          "author": "Connie Willis",
          "title": "DOOMSDAY BOOK"
      },
      {
          "author": "Frank Herbert",
          "title": "DUNE"
      },
      {
          "author": "Maureen F. McHugh",
          "title": "CHINA MOUNTAIN ZHANG"
      },
      {
          "author": "Joe Haldeman",
          "title": "THE FOREVER WAR"
      },
      {
          "author": "Kate Wilhelm",
          "title": "WHERE LATE THE SWEET BIRDS SANG"
      },
      {
          "author": "Orson Scott Card",
          "title": "ENDER'S GAME"
      },
      {
          "author": "Daniel Keyes",
          "title": "FLOWERS FOR ALGERNON"
      }
  ] 
  </code></pre>