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; // 获取上传进度
	}
	...
})

posted on 2020-05-08 09:28  路过君  阅读(70)  评论(0编辑  收藏  举报

导航