使用Uploadify时,onComplete和onCompleteAll事件无法触发 [英] onComplete and onCompleteAll events failing to fire when using Uploadify

查看:206
本文介绍了使用Uploadify时,onComplete和onCompleteAll事件无法触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用uploadify(www.uploadify.com)将图像上传到我的网站,它的工作非常精美,直到你尝试稍微扩展它为止。我试图让它在上传文件后从列表中删除排队的文件。为此,您将初始化uploadify:

I have been using uploadify (www.uploadify.com) to upload images to my website, and it works beautifully until you try to expand on it a little. Im trying to get it to remove a queued up file from the list once that file has been uploaded. To do this, you would initialize uploadify as such:

            $("#fileUpload").uploadify({
            'uploader': '/scripts/uploadify.swf',
            'cancelImg': '/images/cancel.png',
            'script': '/Album/Manage/',
            'fileDesc': 'Image Files',
            'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
            'multi': true,
            'auto': false,
            'simUploadLimit': 3,
            'scriptData': {'album_id':'7'},
            onComplete: function(event, queueID, fileObj, response, data){
                alert(queueID); 
            }
        });

在上面的示例中,您将替换 alert(queueID) with $(#fileUpload)。uploadifyCancel(queueID) - 我只是有警报让我知道事件发生时 - 从未发生过。我使用IE和Firefox并没有任何区别。有没有人有这方面的经验?

In the above example, you'd replace alert(queueID) with $("#fileUpload").uploadifyCancel(queueID) - I just have the alert to let me know when the event fires - which never happens. I have used IE and Firefox and no difference in either. Does anyone have any experience with this?

推荐答案

已解决!

是的,我收集的是关于整个互联网上的唯一一篇文章(包括上传文档和支持页面),它描述了 .Net MVC应用程序中的上传的奇怪之处

Right, i gather this is about the only article on the entire internet (including the Uploadify documentation and support pages) that describes the quirks of Uploadify in a .Net MVC application

经过大量测试后,我看到:

Having done extensive testing, I have seen that:


  1. 如果接受上传文件的脚本(在uploadify初始化代码中指定为'script':'/ Album / Manage /')不返回任何内容,Uploadify的响应事件不会触发 - 我收集错误会停止处理。我的脚本是控制器中的一个操作,其返回类型是字符串。如果出现错误,则将错误作为字符串返回,否则返回任何内容。我所做的就是让它返回'OK',如果没有出错而不是什么。

  1. If the script that accepts the uploaded files (specified in the uploadify initialize code as 'script': '/Album/Manage/') does not return anything, Uploadify's response events dont fire - I gather that an error stops it processing. My script was an action in a controller whose return type was string. If there was an error, it returned the error as a string, otherwise returned nothing. All I did to fix this was make it return 'OK' if nothing went wrong instead of nothing.

传递脚本数据(在uploadify中指定初始化为'scriptData':{'album_id':'7'} )我这样做的方式也导致了错误 - 我还没有找到原因(和RonnieSan,他的父亲上传,似乎没有看到任何问题)所以如果有人知道也许他们可以回复这篇文章

Passing script data (specified in the uploadify initialize as 'scriptData': {'album_id':'7'}) the way I was doing it was ALSO causing an error - I havent worked out why (and RonnieSan, the father of Uploadify, didnt seem to see anything wrong with it) so if anyone does know maybe they can respond to this post

你不能在活动周围放单引号处理程序,例如 onComplete:function(event,queueID,fileObj,response,data){...}

You MUST NOT put single quotes around the event handlers e.g. onComplete: function(event, queueID, fileObj, response, data) { ... }

希望这会有所帮助 - 如果有人需要.Net MVC实施方面的帮助,请给我留言。

Hope this helps - if anyone needs assistance with .Net MVC implementation, just drop me a message.

这篇关于使用Uploadify时,onComplete和onCompleteAll事件无法触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆