I've never really used AJAX before so I'm trying to get familiar. I have an html page:
<html>
<script type="text/javascript" src="jquery-1.12.3.min.js"></script>
<script>
    function write(){
        $.ajax({
        type: 'POST',
        url: "write.php",
        data: "something",
        success: function(result) {
            alert('the data was successfully sent to the server');
        }
        })
    }
</script>
Click to write some stuff
<a href="javascript:write()" class="write">Write</a>
</html>
And the associated write.php file in the same directory:
<?php
error_reporting(E_ALL);
$data = $_POST['data'];
$f = fopen('file.txt', 'w+');
fwrite($f, $data);
fclose($f);
?>
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
 
    