I'm calling a PHP Script to genereta an excel file and then download it on the fly
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment;filename=iva.xls");
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save('php://output');
After this code I finish with:
$aReturn[]= array('result'=>true);
exit(json_encode($aReturn));
At the first moment I start calling this PHP using a submit button... then (trying to get a progress bar) I decided to call this php using javascript with following code:
$.messager.progress();
var urlProtax="taxes/processtax.php?start=" + cStartDate + '&end='+ cEndDate ;
$('#taxesForm').form('submit',{
url: urlProtax,
onSubmit: function(datt){
var isValid = $(this).form('validate');
if (!isValid){
$.messager.progress('close');
}
return isValid;
},
success: function(jdatos){
alert('alert data '+ jdatos);
data = eval('('+jdatos+')');
if(data[0]['result']===true){
$.messager.progress('close');
$('#taxesWin').window('close');
return true;
}else{
$.messager.progress('close');
var iderror = data[0]['error'];
$.messager.alert("ERROR (" + iderror +")" , gt.gettext('Unknown Error'), 'error');
$('#taxesWin').window('close');
}
},
error: function(xhr) {
alert('Error! Status = ' + xhr.status);}
});
Excel file is being created fine!!! but I never get the json response to close progress bar.
Kind Regards,
Excel files are binary, JSON doesn't support binary formats directly. You might have better luck if you use an ascii format like CSV
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.