我正在设置一些导出到 excel 的 html,并通过 jquery $.post 执行此操作。结果是数据
$.post('/exportToExcel.php', function(data) {
// data is the file i want to download now... how to trigger it?
});
数据是来自服务器的返回值(文件),只需执行警报(数据)将输出一个更大的窗口,其中充满了LOL。 如何触发以便能够下载文件?
你不能使用 Ajax 来做到这一点。在 iframe 中加载文件,并将此 HTTP 标头与文件一起发送:
Content-Disposition: attachment