I've been trying to get a script to work that calls a PHP file into a jQuery script using AJAX.
var dataString = 'Submit=Set';
$.ajax({
type: "POST",
url: "./inc/php/file.php",
dataType: "json",
data: dataString,
success: function(data) {
$('.error').html(data.errormsg+' OK.');
},
error: function(data) {
$('.error').html(data.errormsg+' OH NO.');
}
});
and it's calling this bit of PHP
$blogstatus =array();
$blogstatus['errormsg'] = 'NOTHING';
if(isset($_POST['Submit'])){
$blogstatus['errormsg'] = 'FIRST';
if (file_exists('/files/subfolder/')){
$blogstatus['errormsg'] = 'exists';
}else{
$blogstatus['errormsg'] = 'YES';
mkdir('./files/subfolder/',0777);
}
echo json_encode($blogstatus);
If i take the mkdir out everything runs fine and i can call errormsg. I've tried running the mkdir without the ajax call in a standard PHP script, and that worked. Everytime i put the mkdir into the script i get the errormsg variable as undefined and the script fails.
Im fairly new to using jquery so it maybe something simple im over looking. cheers for any heelp