我正在使用Jquery File Uploadify插件进行文档上传,其中多次为true,当我在OnComplete函数中使用alert时,在上传文档时会显示多个警报..
function loadSwf(){
$("#fileuploader").fileUpload({
'uploader': "@Url.Content("~/Scripts/FileUpload/uploader.swf")",
'cancelImg': "@Url.Content("~/Content/Images/clearBtn.png")",
'buttonText': 'Browse Files',
//'buttonImg' : "@Url.Content("~/Content/Images/attachDoc.png")",
'script': "@Url.Content("~/Documents/Upload/")",
'folder': "@Url.Content("~/Documents/")",
//'fileDesc': 'Documents Files',
'fileExt': '*.pdf;*.doc;*.ppt;*.xls',
'multi': true,
'auto': false,
'scriptData': {'ActivityID': $('[id="ActivityID"]').val(), 'Description' : "test" },
'onComplete': function(settings, data) {
alert("File Uploaded Successfully");
}
});
}
此代码适用于上传一个文件。 但是当我上传多个文件时,我收到每个文件的警报消息! 如何在上传所有文件后仅获取一次警报消息,而不是每个文件一个警报。
答案 0 :(得分:1)
您需要使用 onQueueComplete 事件
$("#fileuploader").fileUpload({
'uploader': "@Url.Content("~/Scripts/FileUpload/uploader.swf")",
'cancelImg': "@Url.Content("~/Content/Images/clearBtn.png")",
'buttonText': 'Browse Files',
//'buttonImg' : "@Url.Content("~/Content/Images/attachDoc.png")",
'script': "@Url.Content("~/Documents/Upload/")",
'folder': "@Url.Content("~/Documents/")",
//'fileDesc': 'Documents Files',
'fileExt': '*.pdf;*.doc;*.ppt;*.xls',
'multi': true,
'auto': false,
'scriptData': {'ActivityID': $('[id="ActivityID"]').val(), 'Description' : "test" },
'onQueueComplete' : function(queueData) {
alert("Files Uploaded Successfully");
}
}
});