Xhr上传进度事件在ubuntu下的firefox中无效

时间:2015-09-04 23:13:28

标签: javascript firefox ubuntu xmlhttprequest progress

以下代码在windows和linux(Ubuntu)下的chrome中工作正常,但firefox在windows下运行而不是Linux(Ubuntu):

上传完成后,进度会触发一次!

$.ajax({
   type: POST,
   url: "upload.php",
   data: [formdata object],
   dataType: "json",
   xhr: function() {
        var progressXhr = $.ajaxSettings.xhr();
        if(progressXhr.upload){
            progressXhr.upload.addEventListener('progress',progressHandlingFunction, false);
        }
        return progressXhr;
   },
   beforeSend: function(jqXHR){
    $("#upload_div").show();
   },
   complete: function(jqXHR, textStatus){
    $("#upload_div").hide();
   }
});

function progressHandlingFunction(e){
    percent = (e.loaded * 100) / e.total;
    $("#upload_div").html("%" + percent);
}

0 个答案:

没有答案