本节主要介绍ajax下载插件 - jquery.fileDownload,插件地址:https://github.com/johnculviner/jquery.fileDownload。
本框架的表格导出、datagrid的导出(exportOption参数的type='file'时)使用了该插件。
示例代码:
<script type="text/javascript">
function doc_filedownload1(a) {
$.fileDownload($(a).attr('href'), {
failCallback: function(responseHtml, url) {
if (responseHtml.trim().startsWith('{')) responseHtml = responseHtml.toObj()
$(a).bjuiajax('ajaxDone', responseHtml)
}
})
}
</script>
<a href="Book1.xlsx" onclick="doc_filedownload1(this); return false;">点我下载一个文件</a>
示例代码:
<script type="text/javascript">
function doc_filedownload1(a) {
$.fileDownload($(a).attr('href'), {
failCallback: function(responseHtml, url) {
if (responseHtml.trim().startsWith('{')) responseHtml = responseHtml.toObj()
$(a).bjuiajax('ajaxDone', responseHtml)
}
})
}
</script>
<a href="ajaxDoneErr.html" onclick="doc_filedownload1(this); return false;">点我下载一个文件</a>