How to return pdf document from controller with ajax call in MVC app
I have an @Html.Action link that currently works for returning the user a
pdf document from the controller. I want to be able to use an ajax call to
perform the same function but I'm stuck on how or even if this can be
done. I have tried several different iterations but I never get the pdf to
download from the browser window. Here is what I have so far:
$('#Button1').click(function () {
var poNum = "51970";
$.ajax({
type: "GET",
data: "id= " + poNum,
url: '@Url.Action("PoReport", new { controller = "LogisticsTools"})'
});
});
I can copy the Request URL from the Headers window in Chrome Dev Tools and
paste it into a new page and the pdf is downloaded. I can see the pdf code
in the Response window also but it just doesn't get downloaded when the
button is clicked. What am I missing?
No comments:
Post a Comment