Similar to POST to server, receive PDF, deliver to user w/ jQuery But that doesn't seem to be working here...
I need to POST a request to a server, with a payload of name/value pairs. The server respondes by sending a PDF file
All the user needs to know is that, after clicking a pdf button on the page they get whatever the browser default behavior is (i.e. save or view).
So, the call is a simple one (I think)
$.ajax({
url:"http://blah.com/etc",
data:{filename:'output.pdf', foo:'foo', bar:'bar', baz:'baz'},
type:"POST"
});
That's all the server needs to do its stuff and return output.pdf
It looks like it's working fine. Here are the response headers:
Connection:keep-alive
Content-Disposition:attachment; filename="output.pdf"
Content-Length:17896
Content-Type:application/pdf
Date:Thu, 03 Oct 2013 04:19:06 GMT
Server:nginx
And, if I look at the response in Chrome dev tools, it sure looks like a 17k pdf to me...
The last hurdle though is that the browser (Chrome or FF) is doing nothing, I guess I'm missing the bit that says 'now handle this response as a downloadable file'