How to force download of mpdf files using Ajax

2

I'm trying to download pdf files using the mpdf library.

Calling the php page in the browser works fine.

Example:

require_once 'mpdf/mpdf.php';

$mpdf = new mPDF();

$boleto = '<h3>Boleto</h3>';

$mpdf->WriteHTML($boleto);

$mpdf->Output('teste.pdf',"D");

Now if I try to call it from an html page using ajax its return looks like this:

WhatIcallAjax:

varsalvarBoleto=function(parcelas){$.ajax({url:boletoUrl,data:{"acao": "salvarBoleto",
      "parcelas": parcelas
    },
    dataType: 'json',
    type: 'POST',
    success: function(data) {

    },
    error: function(data) {
      console.warn("mostrar msg de erro");
    }
  });
};

I usually call a new tab for the pdf, but in this case I would like to do it on the ajax page.

    
asked by anonymous 20.06.2016 / 22:17

0 answers