jQuery file upload plugin not calling success callback

Mirage picture Mirage · Oct 15, 2012 · Viewed 11.5k times · Source

I am using jQuery fileupload plugin and I want to do some custom jQuery stuff once fileupload is done

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

Now it says this

Callback for successful upload requests.
$('#fileupload')
       .bind('fileuploaddone', function (e, data) {/* ... */})

Now I have defined this custom function for testing in my own js file

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

But it's not working.

But if I edit the main file in here

  // Callback for successful uploads:
            done: function (e, data) {

Then it works.

Answer

NXT picture NXT · Mar 14, 2013

Check if the server-side uploading script returns a JSON reply - in my case it didn't work when the reply was empty, but file was uploaded successfully.

So, below is working for me with jQuery 1.9.1 and the newest version of the "jQuery File Upload Plugin" - 5.21.3

$("#fileupload").bind("fileuploaddone", function (e, data) {
    console.log("fileuploaddone event fired");
});