我的变量范围有问题,我不知道我做错了什么! 我想从ajax成功范围中获取文件路径,但它不起作用。我的错误在哪里都有胶水。
问候!
var uploadPathPicture;
var uploadPictureFileData = $('#profilbild').prop('files')[0];
var uploadPictureFileDataFormData = new FormData();
uploadPictureFileDataFormData.append('file', uploadPictureFileData);
uploadPictureFileDataFormData.append('mail', $('#mail').val());
$.ajax({
type: 'POST',
url: '../php/uploadPicture.php',
data: uploadPictureFileDataFormData,
dataType: 'text',
cache: false,
processData: false,
contentType: false,
success: function(result)
{
//uploadPathPicture = result;
uploadPathPicture = "huhu";
console.log(uploadPathPicture);
}
});
alert(uploadPathPicture);