javascript - 无法使用 jquery 和 php $_GET 导出 html 表

标签 javascript php jquery excel

我下载的表格只打印标题,不显示任何内容。 我正在按照此处的教程进行操作:http://webslesson.blogspot.in/2016/02/export-mysql-data-to-excel-in-php-php-tutorial.html

我尝试过的以下插件无法呈现我的大量数据 1.clarketm(合并行) 2.(尝试过但无法渲染大量数据)https://github.com/kayalshri/tableExport.jquery.plugin

我的 HTML DOM 是 (index.php)

<div id="allTables">
    <table border="2" width="100%">
                <tr>
                    <th width="30%">Name</th>
                    <th width="20%">Activity on Code Project (%)</th>
                    <th width="10%">Activity on C# Corner (%)</th>
                    <th width="10%">Activity on Asp Forum (%)</th>
                </tr>
                <tr>
                    <td>Sibeesh</td>
                    <td>100</td>
                    <td>98</td>
                    <td>80</td>
                </tr>
                <tr>
                    <td>Ajay</td>
                    <td>90</td>
                    <td>0</td>
                    <td>50</td>
                </tr>
                    </table>
</div>
<p id="exportexcel">EXport to Excel</p>

<script>
 $(document).ready(function () {
    $('#exportexcel').click(function(){
          var excel_data = $('#allTables').html();
          console.log(excel_data);
          var page = "excel.php?data="+excel_data;
          console.log(page);
          window.location = page; // here iam sending data to excel.php through get method
 });
</script>

我的excel.php文件是

<?php
  header('Content-Type: application/vnd.ms-excel');
  header('Content-disposition: attachment; filename='.rand().'.xls');
  echo $_GET["data"];
?>

--请帮助我做错了什么,提前致谢

最佳答案

C# Angular (%) 上的事件 - 此行中的“#”导致了问题。对此进行编码将解决上面代码中的问题。

但最好按照建议使用 POST。

关于javascript - 无法使用 jquery 和 php $_GET 导出 html 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39444924/

相关文章:

javascript - Tumblr 分享按钮不起作用

javascript - 使用 javascript 以 dd-mm-yyyy 格式转换 UTC 值?

javascript - 将缺失的数字插入数组中

php - PHP 中的 Walking Dom 将找到的字符串列表替换为 "HTML text"

Javascript 分块文件上传到 PHP 服务器

jquery - contextMenu 破坏 FullCalendar 事件拖动

javascript - 两个 iframe 子级之间使用 postMessage 进行通信

javascript - symfony 发送表单请求而不提交

jquery - 如何使用jquery将序列化字符串转换为数组

javascript - 如何在backbone.js中绑定(bind) "Droppable"和 "Draggable "事件?