0

I have a php script that generate a pdf file. So I have an html page with jquery javascript that do an ajax call at this php script and retrieve the pdf file content. I would that this file will be saved in a location choosed by a save file dialog.

How can I do it?

Thank you so much.

1
  • the php script retrieve some $POST variable useful for pdf generation Commented Aug 9, 2011 at 21:27

1 Answer 1

1

You don't need Ajax - just do a

location.href = "fileURL.php";

(or alternatively, have the user click on a link) and if the headers are set correctly, a download dialog will present itself.

Sign up to request clarification or add additional context in comments.

4 Comments

Chrome usually opens its built in pdf viewer, but there's the Content-disposition: attachment header.
i think it is not useful because the pdf file is generated passing some $POST variable to the php script
@michele then create a form with the POST method, and submit it, which will then trigger the download. You can't use Ajax for this, it's impossible to start a file download that way
I can't create a form...how can I do? At the moment I have returned via $ajax the pdf content and I would visualize it or save somewhere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.