Hello I'm trying to generate and download excel file via Ajax, but unfortunately I'm getting this error not well-formed
and nothing more specific.. I've checked all the variables etc and I'm sure that there aren't missing any required values..
So basically this is the code which calls PHPExcel script..
$("#myForm").submit(function(e) {
var group_id = <?php echo $group_id; ?>;
var month = <?php echo $month; ?>;
var year = <?php echo $year; ?>;
$.ajax({
url: 'ajax/events_to_excel.php?id='+group_id+'&m='+month+'&y='+year,
type: 'POST',
data: $(this).serialize(),
success: function(data, textStatus, jqXHR) {
//console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
}
}). done(function(data) {
});
e.preventDefault();
});
And this is the ending header code for generating excel document.. (I will not show all the previous code as I know there is everything ok and with no errors, already checked and working in different pages) The only part which gives errors here is the header information..
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
$objWriter->save('php://output');
exit;
P.S. This page isn't giving any output.