当我点击一个按钮时,我想发送一个“ajax下载请求”,所以我是这样尝试的:
javascript:
var xhr = new XMLHttpRequest();
xhr.open("GET", "download.php");
xhr.send();
下载.php:
<?
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename= file.txt");
header("Content-Transfer-Encoding: binary");
readfile("file.txt");
?>
但没有按预期工作,我该怎么办?先感谢您