I have a PHP file where I generate a PDF file using FPDF. If I execute that file, it generates and loads the pdf file on browser. However when I try to generate the PDF file using a button and by using AJAX it does not work.

I am using AJAX since I need to post some variables to PHP to make a query in the database before generating the PDF file.

I looked for solutions on internet but I still do not know how to achieve this.

I want to load the pdf on browser, not download it




var IDDocument = 15;
var Document = 'Invoice';
var ClientID = '205160615';

                type: 'POST', 
                url: 'PDF.php',  
                data: { IDDocument:IDDocument, 
                success: function(data) {
                    //load PDF on browser.

            return false;