开发者

download file from ajax

I'm setting up some htm开发者_Python百科l exporting to excel and is doing this via jquery $.post. The result is data

$.post('/exportToExcel.php', function(data) {    
    // data is the file i want to download now... how to trigger it?
});

data is the returned value (the file) from the server, simply doing alert(data) will output a bigger window full of lol. how to i trigger so the file is able to be download?


You cannot do that using Ajax. Load the file in an iframe, and send this HTTP header with the file:

Content-Disposition: attachment
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜