jQuery FileUpload doesn't trigger 'done'

后端 未结 7 914
陌清茗
陌清茗 2020-12-10 11:04

I use jQuery-File-Upload plugin. I wrote a simple code to test it - and it works, but not without problems. It doesn\'t trigger done, even if the file is upload

相关标签:
7条回答
  • 2020-12-10 11:43
     $(input).fileupload(
    
           url      : '...'
    
          ,dataType : 'json'
          ,sequentialUploads : true
    
           ,add      : function (e,data) {
    
    
               $.each(data.files,function(i,file){
    
                    file.jqXHR = data.submit()
                               .success(function (result, textStatus, jqXHR) {/* ... */})
                               .error(function (jqXHR, textStatus, errorThrown) {
                                 })
                               .complete(function (result, textStatus, jqXHR) { 
                                   //...                   
                                         });
    
                     });
           }
    
    
           ,done: function (e, data) {
             console.log(data);
    
           }
    
    
       });
    

    works perfectly for me;

    differences are

    • the url is set (i hope you just forgot to put it in your snippet here);

    • the way i add file to the download queue

    • sequential upload (?)

    edit :

    The jQuery File Upload plugin makes use of jQuery.ajax() for the file upload requests. This is true even for browsers without support for XHR, thanks to the Iframe Transport plugin.

    The options set for the File Upload plugin are passed to jQuery.ajax() and allow to define any ajax settings or callbacks. The ajax options processData, contentType and cache are set to false for the file uploads to work and should not be changed.

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

    somewhere in your code you could have also changed those ajax settings; anyhow that says that if you have your settings right since it's making use of $.ajax the done cannot be not triggered

    0 讨论(0)
提交回复
热议问题