I'm new to using AJAX methods and am completely stumped with what seems like a very simple procedure.
I'm trying to post data to a php file using AJAX in order to create a folder on my server. No matter what I try it seems as if it's not actually posting data to the php file. I can end up creating a folder directly into the 'users' folder if I remove the $_POST command from the php file... but the second I try to actually create a variable from the posted data so it creates the folder inside of a nested subfolder it fails.
please please please help. I'm losing it. haha.
Someone suggested another thread to solve the problem below... but it still doesn't seem to be working. I'm using the same approach that is suggested in that thread.
Here is my script:
JQuery
<script type="text/javascript>
$('#buildSave').click(function() {
$.ajax({
url: "../php/preparesave.php",
type: "POST",
data: { user : 'Tommy' }
});
});
</javascript>
PHP
<?php
$user = $_POST['user'];
if (!file_exists('../users/' . $user . '/Platoons/')) { mkdir('../users/' . $user . '/Platoons/'); }
?>