我有一个extjs函数,它向服务器发送一个表单,它返回一个带有正确的Content-Disposition ="attachment; filename='test.zip'"头的文件以下载。可以使用浏览器的“正常文件下载”窗口下载该文件。但是,ajax请求的成功回调函数不会被触发,而ajax不确定地等待响应。
有没有一种方法可以告诉ajax函数该文件是否从服务器正确发送?
exportLayer = function(node_id){
Ext.Ajax.request({
method: "GET",
form: "exportForm",
url: "/basqui/layer/shapefile/export/" + node_id + "/",
success: function(r){
html = Ext.decode(r.responseText).html
Ext.get('pageContent').update(html);
},
});
}发布于 2014-07-04 16:46:05
设置responseBytes的binary配置属性,并在响应中获取Ext.Ajax.request属性中的二进制数据。
例如,加载jpeg映像:
Ext.Ajax.request({
url: "/path/to/image/test.jpg",
success: function(xhr) {
var b64encoded = btoa(String.fromCharCode.apply(null, xhr.responseBytes));
var img = Ext.create('Ext.Img', {
src: 'data:application/jpeg;base64,' + b64encoded
});
// add image somewhere
...
}
});https://stackoverflow.com/questions/24577666
复制相似问题