我想用javascript或jquery下载文件。 我必须使用post发送请求,因为我还发送了一些数据用于文件生成。
目前我有:
$.ajax(reportGenerateUrl + reportName,{
contentType : "application/pdf",
processData : false,
method : "POST",
headers : csrfHeaders(),
data: criteria,
success : function(data, status, jqHXR) {
alert('Report generated!');
},
error : function(jqXHR, textStatus, errorThrown, data) {
alert('Unable to get report!');
}
});
我的服务器返回pdf文件,但没有下载提示。我在chrome dev工具的网页中获得文件ooutput。
任何人都可以帮忙吗?