tags:

views:

96

answers:

2

Hi everybody!

I'm trying to display by jquery load() a dynamically generated PDF created by PHP with FPDFlib on a div but what I get is a jam of chars. Is there a way to resolve it?

thanks in advance

I've tried to correct my code in this way but continue to display jam

    $.post("./php/stampa_login.php",
    {piatta:'<? echo $_POST["piatta"] ?>'}, 
    function(data){
        $("#stampa_content").load("./temp/login.pdf")
});

ciao

h.

+2  A: 

That seems to be correct. jQuery's load() fetches an URL through AJAX; if that URL is PDF, it appears as "jam of chars" to the browser, as PDF and HTML aren't compatible at all, the formats are completely different.

What you probably want is to open the PDF as an <object>, but then you're hoping that the user has some PDF plugin installed in their browser. Let's take a step back: what are you trying to achieve here, by displaying a PDF?

Piskvor
I load by JQuery php page that generate PDF; I suppose that this is the problem, may be I can resolve amkeing a post request to php page that generate PDF, save it in local and after load for display...
haltman
A: 

ya, seems to be an output issue. Have you tried header function to output it correctly ? try for proper output or instead of opening the pdf in div, just update the pdf's link there

gajendra.bang
I use these headers: header('Accept-Ranges: bytes'); header("Content-type: application/pdf");
haltman
I don't think that this will work. You will have to update the div with the link for the newly generated pdf.
gajendra.bang