Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

javascript - onComplete and onCompleteAll events failing to fire when using 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); 
            }
        });

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

RESOLVED!

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. 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.

  2. 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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...