0
标题说明了一切,我需要监视数据处理进度。例如,我为MySQL做了一些分块插入操作,并在每个块之后回显进度,如何在前端打印进度?我使用Dropzone.js和我现在的JS代码(简化版本):Dropzone.js上传后进程文件和监视进度
Dropzone.options.importdropzone = {
init: function() {
// I need something like
this.on("backendProccessing",function(response){
return response
})
this.on("success", function(file, response) {
// Success only return after backend finish process
})
}
};
也试过(不工作,没有退换,只能成功):
this.on('xhr',function(){
// get the native XmlHttpRequest object
var xhr = $.ajaxSettings.xhr() ;
// set the onprogress event handler
xhr.onprogress = function(evt){ console.log('Doing') } ;
// set the onload event handler
xhr.onload = function(){ console.log('DONE!') } ;
// return the customized object
return xhr ;
});
所以我需要这样的事情:
this.on("backendProccessing",function(response){
return response
})