views:

355

answers:

0

I'm using the table2CSV plugin and I'm trying to save the results to a file... I'm trying to use the modification mentioned in the "accepted" comment here: http://stackoverflow.com/questions/921037/jquery-table-to-csv-export (where the data is not appended to the url), but I just keep getting a blank csv file.

Right now, the html looks like this:

<form action="/export.php" method="post" target="_blank" onsubmit='$("#reporting").val( $("<div>").append( $("#ReportTable").eq(0).clone() ).html() )'>
<input type="submit" value="Export" />
<input type="hidden" id="datatodisplay" name="datatodisplay" />
</form>

<div id="reportarea">
<table id="report">
<thead>
<tr><th>Col 1</th><th>Col 2</th><th>Col 3</th></tr>
</thead>
<tbody>
<tr>
<td>Data 1</td><td>Data 2</td><td>Data 3</td>
</tr>
</tbody>
</table>
</div>

And the export.php file looks like this:

<?php
header("Content-type: application/vnd.ms-excel; name='excel'");
    header("Content-Disposition: filename=export.csv");
    header("Pragma: no-cache");
    header("Expires: 0");


?>
<html>
<head></head>
<body>
<?php    print $_REQUEST['exportdata']; ?>

</body>
</html>