如何使用jQuery数据表插件将所有数据导出到CSV文件

I want to export the all the result data to be export in CSV file, As of now only current page data is saving in CSV file in jQuery data table

I'm not sure how you want to "export" the data, but you can create the csv contents easily with each() in jQuery. Given your question states that you're using a jQuery data table, you'll already have jQuery imported.

Here is a simple table and the code to parse the contents into csv format. There is a textarea of whose value we set the final "export" data to.

<table id="tbl">
    <tr>
        <th>Col1</th><th>Col2</th><th>Col3</th>
    </tr>
    <tr>
        <td>eggs</td><td>bacon</td><td>milk</td>
    </tr>
    <tr>
        <td>free</td><td>tasty</td><td>food</td>
    </tr>
</table>

<textarea id="output"></textarea>

<script>

$("#output").html(getTableData($("#tbl")));

function getTableData(table) {
    var data = [];
    table.find('tr').each(function (rowIndex, r) {
        var cols = [];
        $(this).find('th,td').each(function (colIndex, c) {
            cols.push(c.textContent);
        });
        data.push(cols + "
");
    });
    return data;
}
</script>

Note: we use .html() on the textarea instead of .val() to avoid extraneous, prepended commas on each line after the first.