weixin_33681778 2015-07-15 04:44 采纳率: 0%
浏览 145

从Ext AJAX下载文件

HI I get a tar file in response Text for the Ext AJAX i need to convert that into a file and download. please let me know any way.

Ext.Ajax.request({
             url : 'download.do',
             method:'POST',
             async:false,
             useDefaultXhrHeader: false,
             cors: true,
             params : configRequest.parameters,
             scope : this,
             success : configRequest.success?configRequest.success:function(response){
                    var res = Ext.decode(response.responseText);
                    if(res.result && res.result=='error'){
                        this.ajaxErrorDisplay(res.err);
                    } }, failure : configRequest.failure?configRequest.failure:function(msg){}});
  • 写回答

1条回答 默认 最新

  • weixin_33704234 2015-07-21 10:11
    关注

    You can create hidden form and then submit try this code.

    getDownloadForm: function(url, requestParams) {
            var hiddenForm = Ext.getCmp('download-file-excel-form');
            if (!hiddenForm) {
                hiddenForm = Ext.create('Ext.form.Panel', {
                  title:'hiddenForm',
                  id: 'download-file-excel-form',                             
                  height:0,
                  width: 0,
                  hidden:true
                });
            }   
    
            hiddenForm.getForm().submit({
                url: url,
                standardSubmit: true,
                method: 'POST', 
                timeout: 120000,
                params: requestParams
            });
        }
    
    评论

报告相同问题?