title: Javascript read specific line in txt file and assign an id to it
body: <p>I have a text file structured like so...</p>
  
  <blockquote>
  <pre><code>Hello
  .
  world
  .
  .
  .
  .
  its me
  </code></pre>
  </blockquote>
  
  <p>I using the following code to read the txt file</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript"&gt;
      function readfileautomatically();
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;body onload="readfileautomatically();"&gt;
  
  &lt;td id="foo"&gt;&lt;/td&gt;
  
  
  
  &lt;script&gt;
  function readfileautomatically () {
  
  var client = new XMLHttpRequest();
  client.open('GET', '/foo.txt');
  client.onreadystatechange = function() {
  alert(client.responseText);
         }
  client.send();
  
  }
  
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Currently with the above I'm able to read the text file and alert the contents. I want to now expand my code and do this.</p>
  
  <p>read foo.txt when page loads</p>
  
  <p>assign line 3 world from the txt file id=line3</p>
  
  <p>assign line 1 hello from the txt file id=line1</p>
  
  <p>So that I can do this: </p>
  
  <pre><code>&lt;td="line3"&gt; world from txt file will be here  &lt;/td&gt;
  &lt;td="line1"&gt; hello from txt file will be here  &lt;/td&gt;
  </code></pre>
  
  <p>Any help given would be greatly appreciated.</p>