---
title: "ext中实现点击button进行下载"
author: "java-xp"
date: "2012-10-26T14:03:44Z"
tags: []
categories: ["Web前端"]
slug: "ext-button"
draft: false
lastmod: "2012-10-26T14:03:44Z"
id: 1705937
url: "https://java-xp.iteye.com/blog/1705937"
---

点击button进行下载
原理是生成一个隐藏的form，提交给它 
{ 
id : 'buttonA', 
text : "导出", 
iconCls: 'export-icon', 
handler : function() { 
  if (!Ext.fly('test')) { 
        var frm = document.createElement('form'); 
        frm.id = 'test'; 
        frm.name = id; 
        frm.style.display = 'none'; 
        document.body.appendChild(frm); 
       } 
       Ext.Ajax.request({ 
        url: 'download.do', 
        form: Ext.fly('test'), 
        method: 'POST', 
       
        isUpload: true 
       }); 
    } 
}