title: ajax not posting to text file
body: <p>I am learning ajax and I have followed a tutorial to post some data to a text file via a php script but I can't get it to work. Is there something I have missed.</p>
  
  <p>the following is the ajax.html page which is a input text with a button to post the data via ajax</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;form name="testform"&gt;
    Off Min:&lt;input name="setOffMin" type="text" id="setOffMin" maxlength="2" size="1"/&gt;&lt;/br&gt;
    
    &lt;button type="button" onclick="postStuff();"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  
  &lt;div id="status"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
   function postStuff(){
    var hr = new XMLHttpRequest();
    var url = "update.php";
    var offM = document.getElementById("setOffMin").value;
    hr.open("POST", url, true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange = function(){
     if (hr.readyState == 4 &amp;&amp; hr.status == 200){
      var return_data = hr.responseText;
      document.getElementById("status").innerHTML = return_data;
     }
    }
    hr.send(offM);
    document.getElementById("status").innerHTML = "processing...";
    
   }
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>this is the update.php file</p>
  
  <pre><code> &lt;?php
  
           $setOffMin = $_POST["offM"];
           $f = fopen("test.txt", "w");
           fwrite($f, $setOffMin);
           fclose($f);
   ?&gt;
  </code></pre>
  
  <p>I have been looking over this code all last night and cannot work out why it is not writing the data to the text file.
  I have run the php script editing out the $_POST and putting in a variable and it does write to the text file. So the php should work and the text file permission is correct. I expect this is the ajax that I have done wrong.
  any help will be great</p>