这可能是非常基本的,但我似乎无法为我的案例找到明确的答案。
我想知道如何确保在其余工作流程可以继续之前执行并完成一个功能
在我下面的脚本中,警报触发为“1”、“3”、“2”,我希望在脚本进入 up.settings.multipart_params 之前完成getsS3policy(file)
preinit: {
UploadFile: function (up, file) {
getS3Policy(file);
alert("3");
up.settings.multipart_params = {
key: path,
filename: file.name,
AWSAccessKeyId: 'AKIAJIRIA6XD4V5MFWCA',
acl: 'private',
policy: policy,
signature: signature,
success_action_status: '201'
}
}
},
});
function getS3Policy(file) {
alert("1");
data = { 'alc': 'private', 'bucket': 'PhotojimaDev', 'key': path, 'file': file.name };
$.ajax({
url: '/desktopmodules/uploader/API/upload/getPolicy',
type: 'POST',
data: data,
success: function (response) {
console.log(response);
if (response) {
policy = response.policy;
signature = response.signature;
alert("2");
}
else {
return "Error";
}
}
});