javascript - Having problems with Ajax function and tcpdf output() -
i using tcpdf create pdf form fields. problem have php script runs fine , creates file ajax fails though script has executed fine.
my ajax
$(document).ready(function() { $("#make-pdf").click(function() { // set variables form data $.ajax({ url: "generate-pdf.php", type: "post", datatype: "json", data: { pdf_name: $('#pdf-name').val(), salutation: $('#salutation').val(), client_name: $('#client-name').val(), client_location: $('#client-location').val(), client_email: $('#client-email').val(), reason_for_saving: $('#reason-for-saving').val(), advisor_name: $('#advisor-name').val(), advisor_email: $('#advisor-email').val(), advisor_contact: $('#advisor-contact').val(), brokerage_name: $("brokerage-name").val() }, success: function(){ alert('success'); }, error:function(){ alert('error'); } }); }); });
the end of php file
$pdf->writehtml($html, true, false, true, false, ''); $pdf->output(__dir__ .'/pdfs/'.$pdf_name.'.pdf', 'f'); return true; //============================================================+ // end of file //============================================================+ } else { return "incorrect request"; } ?>
the function saves file supposed to, i'm getting failed response ajax call. nothing being logged in console either , page seems reload
the problem html button placed. didn't realise <button>
inside <form>
tags submit form though not type submit
Comments
Post a Comment