I'm trying to export some tables generated with PHP from MySQL data. I'm trying to send the info via AJAX to a file with this code:
<?php
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: filename=excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $_POST['table'];
?>
The data comes from this function
function export_excel (id_table) {
var table = $("#" + id_table).html();
$.ajax({
type: 'POST',
url: 'toexcel.php',
data: 'table='+table
});
}
Through Firebug I can see that the table is echoed correctly but it doesn't start any download. Which could be the problem?