OK, I've had a good read through the "Related Questions" section and I haven't found this answer.
I'm using an ajax request to force a php download.  Things are working fine on the PHP end.  Let's say I've got a stream of data called DATA.  Now, I want to pop up a "Save as..." dialog. 
The browser has received a string of hex values. Now, what do I do with this DATA on the client (javascript) side?
This is the PHP code that I'm using, per the link above:
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=$file');
readfile($file);
I've tried
- window.open(DATA) -> hex stream doesn't exist (of course)
- submitting a form with the action as DATA-> same problem
BTW, If I echo the file from PHP then use window.open, it works sometimes. But not for txt files or jpgs etc.
I've seen this working on other sites - how are they doing it? Thanks in advance.
 
    