I have a form in index.php for creating PDF using TCPDF library. What I'm trying to do is show PDF preview before submitting the form when text fields or selects are loosing focus.
3 PHP files:
- the 1st one contains TCPDF functions to create PDF (there is the PDF output setting
$pdf->Output('file_name.pdf', I);
. "I" indicates here rendering PDF to the browser ("F" is for saving the file). - the 2nd one(create_pdf_preview.php) contains including the 1st file and some other stuff
- the 3rd one(create_pdf.php) contains including the 1st file and collecting data to DB
HTML - index.php
<div id="insertingData">
<form id="form" action="create_pdf.php" method="POST">
// some input, textarea and select tags for PDF content with 'c' class
</form>
</div>
<div id="pdfPreview"></div>
AJAX
$('.c').on('blur', function(){
$.ajax({
type: 'POST',
url: 'create_pdf_preview.php',
data: $('#form').serialize(),
success: function(data){
$('#pdfPreview').html(data); // this should be PDF
},
dataType: 'html' // PDF
});
});
So - does anybody know, how to change AJAX to be working? If I would hand more details, please just tell me.
Thank you for any suggestion.