PHPExcel download using ajax call
PHP
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
ob_start();
$objWriter->save("php://output");
$xlsData = ob_get_contents();
ob_end_clean();
$response = array(
'op' => 'ok',
'file' => "data:application/vnd.ms-excel;base64,".base64_encode($xlsData)
);
die(json_encode($response));
JS
$.ajax({
type:'POST',
url:"MY_URL.php",
data: {},
dataType:'json'
}).done(function(data){
var $a = $("<a>");
$a.attr("href",data.file);
$("body").append($a);
$a.attr("download","file.xls");
$a[0].click();
$a.remove();
});
add target=_blank in your ajax success function like below
success: function(){
window.open('http://YOUR_URL','_blank' );
},
otherwise you can handle smartly to open your Excel download link in new tab with jQuery trigger function or etc.