我在项目中使用jQuery表单插件(jquery.form.js)。它在Chrome / FF中工作正常,但在IE8 / 9中,没有调用uploadProgress回调。即使官方网站http://jquery.malsup.com/form/progress.html中的演示也不会更新IE8 / 9中的上传进度。任何提示?感谢。
答案 0 :(得分:8)
来自消息来源:
if (options.uploadProgress) {
// workaround because jqXHR does not expose upload property
s.xhr = function() {
var xhr = jQuery.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.onprogress = function(event) {
var percent = 0;
var position = event.loaded || event.position; /*event.position is deprecated*/
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
options.uploadProgress(event, position, total, percent);
};
}
return xhr;
};
}
它使用ie8 / 9不支持的HTML5功能:
>> "upload" in new XMLHttpRequest
false