如何使用js或jquery中的post下载文件

时间:2018-04-27 11:14:44

标签: javascript jquery

我想用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。

任何人都可以帮忙吗?

0 个答案:

没有答案
相关问题