ajax - POST to server, receive PDF, deliver to user w/ jQuery -


I have a link that the user clicks to get PDF. In jQuery, I create a post Ajax call on the server to get PDFs. PDF comes with the right content header, etc., which usually causes the browser to open the reader plugin, or allows the user to save the PDF.

Since I am getting a PDF W / AJAX call, I am not sure what to do with the data that I get in onsite callback. How can I give data to the browser and allow it to do its default thing with PDF feedback?

itemprop = "text">

You do not need jQuery at all. Simply submit your mail via a form normally, and on the server side, add an HTTP header

  content-dispute: attachment;  

The browser will do its default thing.

Alternatively, if you want to be careful about the notification of any mistake that the PDF generation, you can do so to post your parameters on your server with JQuery. On the server, generate binary content and cache it somewhere for a few minutes, which you have inserted into the user's session, and returned the "success" auxax response on your page (or return if there was an error "Error" response) If the page responds successfully, it can immediately do something like this:

  window.location = "/ get / my / pdf";  

The server then gives cached PDF content, be sure to include the content-description header as above.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -