Rectangle 27 0

javascript Opening the PDF file onclick of a button with AJAX?


<td>
    <input id='$idd' type='button' value='View PDF'class='btn btn-primary' onclick='viewPDF(this.id)' target='_blank' >
</td>
<div id="pdfResult"></div>

<script>
function viewPDF(id){  
    $.ajax({  url: "viewCrf.php",
        data: {'idd' : id},
        type: "POST",
        success: function (data) {
            $("#pdfResult").html(data);
        }
    });
}
</script>
header("Content-type: application/PDF");
output()

Anyway, I found the answer :). I just used GET METHOD and change the button into an href.

Check the Dest parameter of output(). It is I by default... It looks like you specified S... as for "string".

I didn't put anything inside the Output(). Yet it still returning the above picture.

Since using FPDF, you certainly have some PHP code looking like this.

Still not showing anything. I edited my post and added an image of what the alert(data) is returning.

Note