重写AJAX方法通过请求options传入为HTTPXMLRequest.upload.onprogress事件添加监听
代码语言:javascript复制Ext.define('common.patch.Ext.data.request.Ajax', {
override: 'Ext.data.request.Ajax',
newRequest: function (options) {
var xhr = this.callParent([options]);
if (options.uploadprogress) {
xhr.upload.onprogress = options.uploadprogress;
}
return xhr;
}
});
样例
代码语言:javascript复制Ext.Ajax.request({
...
uploadprogress: function (e) {
v progress = e.loaded / e.total; // 获取上传进度
}
...
})