TCPDF not catching PHP variables via jQuery

cerby

New Member
I'm sending user data via jQuery to TCPDF, but it does not display any value received from jQuery in the PDF file. I have even tried to capture the value in a session variable but it still doesn't display. Where am I going wrong? HTML:\[code\]<div id="p"> FOO <input type="text" id="nop" /></div> <div id="e_table"> <table> <thead> <th><h3>ABC</h3></th> <th><h3>PQR</h3></th> <th><h3>XYS</h3></th> </thead> <tbody> <tr> <td>Staff</td> <td><input type="text" id="as" /></td> <td><label id="las">label</label></td> </tr> <tr> <td>Office</td> <td><input type="text" id="bo"/></td> <td><label id="lbo">label</label></td> </tr> <tr> <td>Administrative</td> <td><input type="text" id="mca" /></td> <td><label id="lmca">label</label></td> </tr> </tbody> </table></div>\[/code\]jQuery:\[code\]$('#pdf').click(function() { var nop = $('#nop').val(); var as = $('#as').val(); var las = $('#las').text(); var bo = $('#bo').val(); var lbo = $('#lbo').text(); var mca = $('#mca').val(); var lmca = $('#lmca').text(); var postData = http://stackoverflow.com/questions/9906079/{"nop" : nop, "as" : as, "las" : las, "bo" : bo, "lbo" : lbo, "mca" : mca, "lmca" : lmca }; $.ajax({ type: "POST", url: "pdf.php", data: postData, success: function(data){ window.open("pdf.php"); } }); });\[/code\]TCPDF pdf.php:\[code\]<?phpsession_start(); //============================================================+// Author: Nicola Asuni//// (c) Copyright:// Nicola Asuni// Tecnick.com s.r.l.// Via Della Pace, 11// 09044 Quartucciu (CA)// ITALY// www.tecnick.com// [email protected]//============================================================+/** * @author Nicola Asuni * @since 2009-03-20 */require_once('tcpdf/config/lang/eng.php');require_once('tcpdf/tcpdf.php');// Extend the TCPDF class to create custom Header and Footerclass MYPDF extends TCPDF { // Page footer public function Footer() { // Position at 15 mm from bottom $this->SetY(-15); // Set font $this->SetFont('helvetica', 'B', 8); $this->SetTextColor(247, 147, 29); $this->Cell(0, 10, 'ABC', 0, false, 'C', 0, '', 0, false, 'T', 'M'); }}// create new PDF document$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);// set document information$pdf->SetCreator(PDF_CREATOR);$pdf->SetAuthor('ABC');$pdf->SetTitle('ABC');$pdf->SetSubject('ABC');$pdf->SetKeywords('ABC');// set default header data$pdf->SetHeaderData(false);$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));// set default monospaced font$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);//set margins$pdf->SetMargins(PDF_MARGIN_LEFT, 5, PDF_MARGIN_RIGHT);$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);//set auto page breaks$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);//set image scale factor$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);//set some language-dependent strings$pdf->setLanguageArray($l);// ---------------------------------------------------------// add a page$pdf->AddPage();$pdf->SetFont('helvetica', '', 8);// -----------------------------------------------------------------------------//request parameters $nop = strip_tags($_POST['nop']); $_SESSION['nop'] = $nop; $nop = $_SESSION['nop']; $as = strip_tags($_POST['as']); $las = strip_tags($_POST['las']); $bo = strip_tags($_POST['bo']); $lbo = strip_tags($_POST['lbo']); $mca = strip_tags($_POST['mca']); $lmca = strip_tags($_POST['lmca']);$tbl = <<<EOF <div> <table border="0" cellpadding="5" cellspacing="2"> <tr> <td>FOO</td> <td>$nop</td> </tr> </tbody> </table> </div> <hr> <div> <table border="0" cellpadding="5" cellspacing="2"> <thead> <tr> <th><h3>ABC</h3></th> <th><h3>PQR</h3></th> <th><h3>XYS</h3></th> </tr> </thead> <tbody> <tr> <td>Staff</td> <td>$as</td> <td>$las</td> </tr> <tr> <td>Office</td> <td></td> <td></td> </tr> <tr> <td>Administrative</td> <td></td> <td></td> </tr> </tbody> </table> </div> </div>EOF;$pdf->writeHTML($tbl, true, false, false, false, '');$txt = $nop . 'This'; // print a block of text using Write()$pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0); // -----------------------------------------------------------------------------//Close and output PDF document$pdf->Output('ABC.pdf', 'I');//============================================================+// END OF FILE //============================================================+\[/code\]
 
Top