title: Writing to file using ajax
body: <p>I've never really used AJAX before so I'm trying to get familiar. I have an html page:</p>
  
  <pre><code>&lt;html&gt;
  &lt;script type="text/javascript" src="jquery-1.12.3.min.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
      function write(){
          $.ajax({
          type: 'POST',
          url: "write.php",
          data: "something",
          success: function(result) {
              alert('the data was successfully sent to the server');
          }
          })
      }
  &lt;/script&gt;
  
  Click to write some stuff
  &lt;a href="javascript:write()" class="write"&gt;Write&lt;/a&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the associated write.php file in the same directory:</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  $data = $_POST['data'];
  $f = fopen('file.txt', 'w+');
  fwrite($f, $data);
  fclose($f);
  ?&gt;
  </code></pre>
  
  <p>When I click the link, I get the success message, but the file is not created on the server. Not really sure what to investigate. Have confirmed I have write access to the directory</p>