[英]Download a file on button click and send value to the download file as parameter
Say I have a table on index page that changes dynamically when certain event is triggered. 假设我在索引页面上有一个表,该表在触发某些事件时会动态变化。
Lets say I have another file: excel.php that generates excel sheet. 可以说我还有另一个文件:excel.php,它可以生成excel工作表。
I want to run excel.php file(Which starts downloading an excel file), staying on index page for which I am using following jquery script. 我想运行excel.php文件(开始下载excel文件),并停留在我正在使用以下jquery脚本的索引页上。
$("#user_period_table_excel_btn").on("click", function(ev) {
window.location.href = 'excel.cfm';
ev.preventDefault();
return false;
});
But the problem is I want to add the table htmls on index page to the excel.php file before downloading. 但是问题是我想在下载之前将索引页上的表htmls添加到excel.php文件中。 In other word , I want to pass value in index page to the excel.php file.
换句话说,我想将索引页中的值传递给excel.php文件。
I cannot use get method because the table is very very large. 我不能使用get方法,因为表非常大。
Excel.php Excel.php
$tab_content=/* I want to assign the table html code on index.html page*/
/*php script for generating $tab_content to excel sheet*/
Any help/suggestions is appreciated. 任何帮助/建议表示赞赏。
window.location.href = 'excel.php?param=123';
at the end of excel.php simply output excel file contents 在excel.php的末尾仅输出excel文件内容
header("Content-Disposition: attachment; filename=\"excel.xls");
header("Content-Type: application/force-download");
readfile('excel.xls')
die();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.