簡體   English   中英

單擊按鈕下載文件,然后將值作為參數發送到下載文件

[英]Download a file on button click and send value to the download file as parameter

假設我在索引頁面上有一個表,該表在觸發某些事件時會動態變化。

可以說我還有另一個文件:excel.php,它可以生成excel工作表。

我想運行excel.php文件(開始下載excel文件),並停留在我正在使用以下jquery腳本的索引頁上。

$("#user_period_table_excel_btn").on("click", function(ev) {
    window.location.href = 'excel.cfm';
    ev.preventDefault();
    return false;
});

但是問題是我想在下載之前將索引頁上的表htmls添加到excel.php文件中。 換句話說,我想將索引頁中的值傳遞給excel.php文件。

我不能使用get方法,因為表非常大。

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*/

任何幫助/建議表示贊賞。

window.location.href = 'excel.php?param=123';

在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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM