I'm trying to make my Download function popup with the file to download, it is outputting the binary of the file to the div when i click the link, how can i make it so that when i click the link, it will instead ask me to download it? I know i can do it with querystring and using headers in php, but can i do it with ajax/javascript in a similar way? thanks, here's what i tried:
<html> <head> <script> function Download(plan_name) { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var resp = xmlhttp.responseText; document.getElementById("txtHint").innerHTML=resp; //HOW TO SHOW test.zip in a save-as dialog? } } xmlhttp.open("GET","fetcher.php?file=/raid0/data/naswebsite/Projects/Projects/07-003_Dawson_Mine/Flight\ Plans/Dawson_Sth_1211_AMG_700.zip"); xmlhttp.send(); } </script> </head> <body> <a href="#" onClick="Download();">Test Download</a> <div id="txtHint"></div> </body> </html>