在处理脚本的其余部分之前等待uploadifyUpload()完成

我在这样的脚本中使用uploadifyUpload():

$("#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(); } }); 

正如您所看到的,在上传之前甚至有机会完成表单已发送。 这不是很好cus我需要对’sendartist.php’中的上传文件进行处理。

有没有办法为uploadifyUpload()添加某种回调,以便脚本只有在完成时才会继续?

干杯!

使用onAllComplete事件将您的Ajax调用放在Uploadify设置函数中。 看看文档: http : //www.uploadify.com/documentation/events/onallcomplete/

您可以尝试在设置中进行设置:

 simUploadLimit: 999