0

I am using this great script called jQuery Upload. It can be found here. http://blueimp.github.io/jQuery-File-Upload/

I am loading this script in an iframe on my main page. I need to know when the files are uploaded so I can send a message to some jQuery on my home page and call another function. Its clear this script IS firing after upload because thumbnails show up, etc... but I have no idea what to look for to see where i can modify this script.

I have a very strong suspision that it is doing its work in the js file. I went to their board and asked for help a few days ago and no body seems to be responding.

Thanks for any tips.

3 Answers 3

1

One way to do it is to register a callback. Example:

$('#fileupload').bind('fileuploaddone', function (e, data) {/* ... */})

More information on the callback and a list of all events is available at:

https://github.com/blueimp/jQuery-File-Upload/wiki/Options

Sign up to request clarification or add additional context in comments.

Comments

1

This plugin has callback functionality builtin. . So when the upload is complete it will fire. This also allows you to catch errors as well and do something with those.

$('#fileupload').fileupload({
    add: function (e, data) {
        var jqXHR = data.submit()
            .success(function (result, textStatus, jqXHR) {/* ... */})
            .error(function (jqXHR, textStatus, errorThrown) {/* do something on error */})
            .complete(function (result, textStatus, jqXHR) {/* perform another jQuery func or whatever */});
    }
});

Check the API document here for Callbacks.

12 Comments

How can I detect a "delete" I can't seem to find that option? :)
What do you mean by detect a delete?
When I delete an image, the image fades away and gets deleted but it does not fire the fileupload code that you suggested. This only works with an upload for some reason. I would like to know when a file is deleted too. Does this make sense?
Take a look here and you can see both examples github.com/blueimp/jQuery-File-Upload/wiki/API#wiki-callbacks Notice my code uses the submit portion. So that will submit the form using that code. The method that worked doesn't call the submit. So if you are submitting it yourself that might be why it's not working.
Ok then yes then $('#fileupload').bind('fileuploaddone', function (e, data) {/* ... */}) will work for you. My method is using the special add feature that starts the upload via the submit as shown in the example on their website. So the default is fine too.
|
0

You need to pass a callback function to the done mechanism, I used this in a project of my own quite recently, sample code below:

    $('#fileupload').fileupload({
        dataType : 'json',
        url : '/path/to/file',              
        done : function (e, data) {
           //Code to execute here   
        }
   });

Let me know if you need anything else

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.