1

I have a Servlet that returns a PDF (Jasper Report). When the request comes from an HTML Form, It successfully shows the PDF.

<form method="post" action="../reports/GenerateReport" target="_blank">

I'm new to jQuery and I would like to generate the report using an AJAX request, I now have the following code:

$.post('../reports/GenerateReport', {
    ...
}, function (report) {
    //this ajax call returns a PDF
    //how do I show it?
});

But I don't know what to do with the returned PDF. How do I show it? Thank you.

Alex K
  • 22,315
  • 19
  • 108
  • 236
lxcky
  • 1,668
  • 2
  • 13
  • 26

1 Answers1

0

You can check the following post if it helps in your situation.

window-open-with-pdf-stream-instead-of-pdf-location

Alternately, you can first write this pdf to some server location and then it can be opened using

var script = "window.open('" + pdflocation + "', '_blank');";
Community
  • 1
  • 1
amdg
  • 2,211
  • 1
  • 14
  • 25