下载文件时不显示另存为Diaolog(使用AJAX调用servlet)

时间:2015-05-08 08:48:33

标签: javascript ajax jsp

我点击下载按钮调用下载servlet。该调用是使用XMLHttpRequest对象的AJAX调用。

var xhr = new XMLHttpRequest();

xmlhttp.open("POST","servlet",true); //servlet will be the servlet name       
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    
xmlhttp.send(....); 

xhr.onreadystatechange = function(){
    if (this.readyState == 4 && this.status == 200){

        //some logic
 }}

我得到的错误:

  

尽管Fiddler显示了,但仍未显示“另存为”对话框   回复中的文件。

     

服务器端:标题('Content-type',// mmime类型);   header('Content-Disposition','attachment; filename = test.txt');

0 个答案:

没有答案