ExtJS实现文件下载的方法

前台代码:
Ext.get('outputuser').on('click', function(e){
<wbr>Ext.MessageBox.confirm('提示','确定要导出用户吗?',function(btn){</wbr>
<wbr><wbr>if(btn=="yes"){ <wbr><wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr>Ext.Ajax.request({</wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr>url:"可以获得要下载文件的url",</wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr>success:function(res){</wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr>var obj = Ext.decode(res.responseText);</wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr>//alert(res.responseText);</wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr>window.location.href = obj.path;</wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr>}</wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr>});</wbr></wbr></wbr></wbr>
<wbr><wbr>}</wbr></wbr>
<wbr>})</wbr>
});

后台:
$json = '{"path":"/web/ii.rar"}';
echo $json;

你可能感兴趣的:(ExtJs)