DeboJackson
12-09-2008, 12:40 PM
I am sort of new to html and javascripts and especially Ajax.
I've been stuck with this problem for a while trying to find a good way to program but I just can't think of anything.
I have an html page, there is a button there, with an onclick='generateRtf()'
This function, uses Ajax objects (it handles all browsers) to send a get request to a php script which connects to db, does a lot of work and generates an rtf file
Then it sets the http header so this rtf file would be downloaded:
header('Content-Disposition: attachment; filename='.$fileName.'.rtf');
header('Content-type: application/msword');
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
So if this script is loaded directly the browser prompts for the user for a download and so you can save the file locally.
Problem is how do I do this with my ajax object?
You see, the ajax object receives the file as text and I can write to the screen, do whatever with it, but I cant allow the users to download it.
Any ideas on how to do this?
I've been stuck with this problem for a while trying to find a good way to program but I just can't think of anything.
I have an html page, there is a button there, with an onclick='generateRtf()'
This function, uses Ajax objects (it handles all browsers) to send a get request to a php script which connects to db, does a lot of work and generates an rtf file
Then it sets the http header so this rtf file would be downloaded:
header('Content-Disposition: attachment; filename='.$fileName.'.rtf');
header('Content-type: application/msword');
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
So if this script is loaded directly the browser prompts for the user for a download and so you can save the file locally.
Problem is how do I do this with my ajax object?
You see, the ajax object receives the file as text and I can write to the screen, do whatever with it, but I cant allow the users to download it.
Any ideas on how to do this?