问题描述
我正在像这样的脚本中使用uploadifyUpload():
I'm using uploadifyUpload() from within a script like this:
$("#artist_form").validator({
offset: [0, 100],
position: 'center left',
messageClass: 'arterror'
}).submit(function(e) {
if (!e.isDefaultPrevented()) {
$('#file_upload').uploadifyUpload();
var form = $(this);
var serdata = form.serialize();
$.ajax({
type: "POST",
url: "sendartist.php",
data: serdata,
cache: false,
success: function (html) {
log('inside ajax artist', this, arguments);
if (html=="0") {
alert("An error occurred");
} else {
alert("Sent ok");
}
},
error: function (err) {
log('inside ajax artist', this, arguments);
}
});
e.preventDefault();
}
});
如您所见,在上传之前,甚至有机会完成表格的发送.这不是一个好习惯,我需要对"sendartist.php"中的上传文件进行处理.
As you can see, before the upload even has a chance to complete the form has been sent. This isn't good cus I need to do something with the uploaded files in 'sendartist.php' thats doing the processing.
是否可以将某种回调添加到uploadifyUpload()中,以使脚本仅在完成后才继续?
Is there a way to add some sort of callback to uploadifyUpload() so that the script only continues if it's complete?
干杯!
推荐答案
使用其onAllComplete事件将Ajax调用放入Uploadify设置函数中.看一下文档: http://www.uploadify.com/documentation/events/onallcomplete/
Place your Ajax call within Uploadify setup function using its onAllComplete event.Have a look at documentation: http://www.uploadify.com/documentation/events/onallcomplete/
这篇关于在处理其余脚本之前,等待uploadifyUpload()完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!