POST XML to server, receive PDF
Posted
by Shaggy Frog
on Stack Overflow
See other posts from Stack Overflow
or by Shaggy Frog
Published on 2010-05-27T23:46:29Z
Indexed on
2010/05/27
23:51 UTC
Read the original article
Hit count: 284
Similar to this question, we are developing a Web app where the client clicks a button to receive a PDF from the server. Right now we're using the .ajax() method with jQuery to POST the data the backend needs to generate the PDF (we're sending XML) when the button is pressed, and then the backend is generating the PDF entirely in-memory and sending it back as application/pdf in the HTTP response.
One answer to that question requires the server-side save the PDF to disk so it can give back a URL for the client to GET. But I don't want the backend caching content at all.
The other answer suggests the use of a jQuery plugin, but when you look at its code, it's actually generating a form
element and then submitting the form
. That method will not work for us since we are sending XML data in the body of the HTTP request.
Is there a way to have the browser open up the PDF without caching the PDF server-side, and without requiring us to throw out our send-data-to-the-server-using-XML solution?
(I'd like the browser to behave like it does when a form
element is submitted -- a POST is made and then the browser looks at the Content-type
header to determine what to do next, like load the PDF in the browser window, a la Safari)
© Stack Overflow or respective owner