The way my web app is supposed to work is that the user fills out a form and then the AJAX sends the form data to a PHP file that generates a PDF (using xpdf). Then the generated PDF should be available for download on the HTML page with the AJAX.
If I open pdf.php directly in the browser it works fine. However I need to figure out how to connect it with the AJAX so that it sends the generated PDF back to the AJAX and the user can simply click a button on the page to download it.
AJAX:
$.ajax({
url: 'pdf.php',
type: 'POST',
data: pdfData
})
.done(function(response){
});
pdf.php:
<?php
include('fpdf.php');
include('fpdi.php');
// initiate FPDI
$pdf =& new FPDI();
// add a page
$pdf->AddPage();
...
$pdf->Output('address.pdf', 'D');
?>