我想使用Ajax调用生成PDF报告,我可以使用下面的语句成功生成它但是如何使用AJAX调用实现这一点
$('#printReports').click(function () {
window.location.href = "/StoreProfile/PrintReports?selectedReport=" + $("#bindReports").val() + "&storeNumber=" + '@Model.StoreProfileAssociation.StoreNumber';
}
而不是上面的声明我希望它使用AJAX生成PDF,下面的代码我已经尝试但似乎不起作用,请帮助我提出一些好的建议
$('#printReports').click(function () {
$.ajax(
{
type: 'GET',
data: { 'selectedReport': selectedReport },
datatype: "json",
url: "/StoreProfile/PrintReports",
success: function (data) {
var json = data;
console.log(json);
//$('#printReports').html('');
//$('#_genericReport').html(data);
window.location.href = "/StoreProfile/PrintReports";
},
error: function (result) {
showAlert("Error", 'Failed to load the result');
}
})
I tried in the above method but didn't worked.