【问题标题】:Export from PHP to CSV without the header and footer从 PHP 导出到 CSV,不带页眉和页脚
【发布时间】:2013-06-19 09:08:18
【问题描述】:

我在我的网站中使用模板,所以当我使用 Javascript 从 PHP 导出到 CSV 时:

window.location="index.php/exporter_resultats";

我得到一个包含整个页面的 html 的 CSV 文件,而不仅仅是我需要的数据。

有没有一种方法可以导出页面特定 div 的内容,而不需要页眉和页脚以及其他内容?

【问题讨论】:

标签: php javascript jquery csv export


【解决方案1】:

您可以使用 jquery 获取特定 div 或元素的内容,然后使用 js 对其进行解析。 在您的 html 中:

<div id="myDiv">I just want this text</div>

在你的 js 中:

var divContent = $("#myDiv").html();

这至少会让您获得要解析的特定内容,而不是整个页面。

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 1970-01-01
    • 1970-01-01
    • 2017-05-26
    • 2013-04-08
    • 1970-01-01
    相关资源
    最近更新 更多