在jQuery 1.5+ 的jqXHR上监听文件上传进度(xhr.upload)
XMLHttpRequest.upload
在Firefox, Google Chrome and Safari中,如果通过XMLHttpRequest上传文件,
是可以通过监听XMLHttpRequest.upload对象的progress事件来查看进度的。
function onprogress(evt) { // display uploading progress infomation...};var xhr_provider = function() { var xhr = jQuery.ajaxSettings.xhr(); if(onprogress && xhr.upload) { xhr.upload.addEventListener('progress', onprogress, false); } return xhr;};$.ajax({ url: url, timeout: 5*60*1000, type : 'post', data: bb.getBlob(), contentType: 'multipart/form-data; boundary=' + boundary, processData: false, xhr: xhr_provider, success: function() {}, error: function() {}});?