我在ajax事件服务器端创建一个word文档,并作为响应如果没有错误我想推它下载。是否有可能与jQuery的Ajax?我的代码看起来在这一刻,因为它遵循jquery ajax响应下载文件
$.ajax({
type: "POST",
url: 'docsx.php',
data: $("#edit_form").serialize(), // serializes the form's elements.
success: function(data)
{
**here should be fired the download** // show response from the php script.
},
error:function(){
alert('Es gibt ein Fehler bei Daten übetragung!');
}
});
你可以只重定向到一个网页,会强制下载(通过设置适当的头)。另一种选择是使用[this](http://filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/),但不幸的是它还没准备好。看起来他们还在试验它。 –
感谢您的反馈,我以前一直在看你的建议链接,但没有在我的案件工作,但是你的第一个建议是做我想做的。非常感谢 – kakuki