javascript - can't get server response when using dropzone.js version 4 -


i'm using dropzone.js version 4 upload files webpage server. upload works fine, i'm trying server response. i'm creating dz programmatically.

  // create dropzone         var dz='    <form action="../home/cgi/newfileupload.exe" ';         dz+='         class="dropzone"';                     dz+='         id="my-awesome-dropzone">';         dz+='         <input type="hidden" name="token" value="token2send"';         dz+='   </form>';         $("#mydz").prepend(dz);  // there div called mydz    settimeout(function(){                      // init dynamic dropzone        myawesomedropzone=$("#my-awesome-dropzone").dropzone();              // configure                     dropzone.options.myawesomedropzone  = {                         init: function() {                             this.on("success", function(file, responsetext) {                                  // should response server                                  alert(responsetext);                             });                           }                     };                      },1000);         

when run code, there no "alert" @ all, file uploads correctly.

here got work:

  // create dropzone         var dz='    <form action="../home/cgi/newfileupload.exe" ';         dz+='         class="dropzone"';                     dz+='         id="my-dropzone">';         dz+='         <input type="hidden" name="token" value="'+tkn+'"';         dz+='   </form>';             $("#mydz").prepend(dz);        settimeout(function(){                        dropzone.autodiscover = false;             // init dynamic dropzone            var mydropzone = new dropzone("#my-dropzone");             // file api: https://developer.mozilla.org/en-us/docs/web/api/file            mydropzone.on("success",function(file,r){                 // r server response                  alert(file.name+" "+r);            });        },500); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -