title: Javascript: Read Text File using AJAX
body: <p>Can't get AJAX to work! I have a marquee on a website, got it working! But I want it to find the text of the marquee in a text file, and I want it to read the text in the text file (which is one line) and assign it to the variable called <code>content</code>, which is a global variable in the script tag.</p>
  
  <p>When I run the website (local IIS), the marquee text is: "undefined" (without the quotes).</p>
  
  <p>Why isn't it assigning the text to the variable <code>content</code>?</p>
  
  <pre><code>    var content
  
      function loadXMLDoc()
      {   
          var textfile;
          if (window.XMLHttpRequest)
          { 
              textfile = new XMLHttpRequest(); 
          }
          textfile.onreadystatechange = function ()
          {   
              if (textfile.readyState == 4 &amp;&amp; textfile.status == 200)
              { 
                  content = textfile.responseText; 
              }
          }
          textfile.open("GET", "C:\Users\Fares\Dropbox\Sync\College\Computing\DeltaOne\MarqueeText.txt", true);
          textfile.send();
      }
  </code></pre>
  
  <p><strong>EDIT:</strong> A million thanks to @kuncajs, as he pointed out I forgot to call the function! :) Fixed! Thanks to everyone else!</p>