我正在尝试在ajax按钮单击上生成pdf,但结果未显示在pdf中。
ajax
$('#Expnpdf').on('click', function() {
var data2_value = $('#expenses').val();
$.ajax({
type: 'post',
url: 'expense_report_pdf',
data: {type:data2_value},
success: function (data) {
if (data.length > 0) {
var url = data['expense_report_pdf'];
window.location = url;
}
}
});
});
功能
public function expense_report_pdf()
{
$data=$this->Report_model->expense_report();
$this->load->library('Pdf');
$pdf = new TCPDF('L', 'mm', array(400,400), true, 'UTF-8', false);
$pdf->SetTitle('Enquiry Report');
$pdf->SetHeaderMargin(20);
$pdf->SetTopMargin(10);
$pdf->setFooterMargin(10);
$pdf->SetAutoPageBreak(true);
$pdf->SetAuthor('Author');
$pdf->SetDisplayMode('real', 'default');
$pdf->AddPage();
$html = $this->load->view('Admin/exp_pdf',$data,true);
$pdf->writeHTML($html, true, false, true, false, '');
ob_end_clean();
$pdf->Output();
}
success
的结果为true,但没有生成pdf,如何解决此问题?请帮帮我!