title: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
body: <p>Okay so I'm trying to pull data from a json file that holds the status of a few LEDs, etc. I have a script that runs a few times a second and pulls the data and the webpage loads it. The problem is, after about 20+ times of the server reading the json file, eventually it will throw this error.</p>
  
  <blockquote>
    <p>SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of
    the JSON data</p>
  </blockquote>
  
  <pre><code>// For toggling the LED/switch status indicators using the json data
  $(document).ready(function() {
      (function worker() {
          $.ajax({
              url: 'server_info.json',
              success: function(data) {
                  var json = $.parseJSON(data);
                  console.log(json); 
                  if (json.led_1 == "off") {
                      // do stuff
                  }        
                  if (json.led_2 == "off") {
                      // do stuff
                  } 
                  if (json.led_3 == "off") {
                      // do stuff
                  }        
              },
              complete: function() {
                  // Schedule the next request when the current one's complete
                  setTimeout(worker, 250);
              }
          });
      })();
  });
  </code></pre>
  
  <p>The json file looks like this:</p>
  
  <pre><code>{ "led_1": "on", "led_2": "on", "led_3": "on" } 
  </code></pre>
  
  <p>It seems to me that the json data is always properly formatted. I'm not understanding where the error is coming from. Any ideas?</p>