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

查看:14
本文介绍了使用 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) 替换为 $("#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?

推荐答案

已解决!

好吧,我认为这是整个互联网(包括 Uploadify 文档和支持页面)上唯一一篇描述 Uploadify 在 .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'})我这样做的方式也导致错误 - 我还没有弄清楚原因(Uploadify 之父 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天全站免登陆