EXTJS7 监听AJAX异步上传文件进度
重写AJAX方法通过请求options传入为HTTPXMLRequest.upload.onprogress事件添加监听
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;
}
});
样例
Ext.Ajax.request({
...
uploadprogress: function (e) {
v progress = e.loaded / e.total; // 获取上传进度
}
...
})