title: "Unexpected end of input" of the doctype tag when running AJAX asynchronous but not when synchronous
body: <p>I've got this project where I get the error <code>Uncaught SyntaxError: Unexpected end of input</code> on line 1 of my HTML code, which is the DOCTYPE tag. I don't know how to fix this since the tag doesn't have a closing tag.. I only get this error when running the AJAX asynchronous, which I must do or the AJAX just gets stuck in an infinite loop manner.. I'm using this to interact with an API that grabs all the red days of a calendar year. Any ideas on how I fix this? I've been searching for an answer but I haven't found any that matches my problem. </p>
  
  <p>Here's my AJAX code: </p>
  
  <pre><code>    var xhr = new XMLHttpRequest();
          xhr.open('GET', 'http://api.dryg.net/dagar/v2/' + year, true);
          xhr.send();
      var json = JSON.parse(xhr.responseText);
  
      for (item in json.dagar) {
  
          var propertyObject = json.dagar[item];
  
          for (subitem in propertyObject) {
  
              if (subitem === 'röd dag') {
  
                  var redDay = propertyObject[subitem];
  
                  if (redDay === 'Ja') {
  
                      calendar.markRedDays(propertyObject.datum);
                      break;
                  }
              }
          }
      }
  </code></pre>
  
  <p>And this is the HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt; &lt;--- This is where the error points to
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Online Calender&lt;/title&gt;
      &lt;script src='https://cdn.firebase.com/js/client/1.1.1/firebase.js'&gt;&lt;/script&gt;
      &lt;link href='http://fonts.googleapis.com/css?family=Port+Lligat+Sans' rel='stylesheet' type='text/css'&gt;
      &lt;link rel='stylesheet' type='text/css' href='style.css'&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'&gt;&lt;/script&gt;
      &lt;script src="firebase1.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>