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; // 获取上传进度
	}
	...
})
原创文章 68 获赞 61 访问量 2906

猜你喜欢

转载自blog.csdn.net/zhoudingding/article/details/105988079