Papa De Beau
Papa De Beau

Reputation: 3828

modifying a jQuery Upload Demo Script

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.

Upvotes: 0

Views: 72

Answers (3)

Streamside
Streamside

Reputation: 332

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

Upvotes: 1

Panama Jack
Panama Jack

Reputation: 24468

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.

Upvotes: 1

palacealex
palacealex

Reputation: 94

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

Upvotes: 0

Related Questions