以下代码在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);
}