title: Write line to text file with AJAX XMLHttpRequest
body: <p>Here is my javascript function that reads from the file every second and outputs it:</p>
  
  <pre><code>var timer;
  var url = "http://.../testdata.txt";
  function ajaxcall() {
      var lines;
      var alltext;
      request = new XMLHttpRequest();
      request.open("GET", url, true);
      request.onreadystatechange = function() {
          if (request.readyState === 4) {  // document is ready to parse.
              if (request.status === 200) {  // file is found
                  allText = request.responseText;
                  lines = request.responseText.split("\n");
                  document.getElementById("test").innerHTML = "";
                  for (i in lines) {
                      document.getElementById("test").innerHTML += lines[i] + "&lt;br&gt;";
                  }
              }
          }
      }
      request.send();
  }
  timer = setInterval(ajaxcall, 1000);
  </code></pre>
  
  <p>I haven't got the hang of AJAX yet so I tried to make a similar way to write into the file using what I read on the internet:</p>
  
  <pre><code>function chat() {
      request = new XMLHttpRequest();
      request.open("POST", url, true);
      request.send("\n" + document.getElementById("chatbox").value);
  }
  </code></pre>
  
  <p>However that does absolutely nothing and I don't understand why. The element "chatbox" is input type textbox and chat() is called by input type submit.</p>