Reputation: 677
This is the web method definition:
[HttpPost]
public FileResult GenerateReport(string Id) {
//............Code .................//
return File(response.ReportContents, "application/pdf");
}
and here is my jQuery ajax call to web method:
$(".ValuationReport").bind('click', function () {
$.ajax({
url: "https://localhost.com/Report/GenerateReport
type: "POST",
data: { Id: "00AFCA2F-6809-4FF4-BA32-125EAEBB1321" },
success: function (data) {
},
error: function () {
alert("error");
}
});
});
Please help me.
Upvotes: 0
Views: 1832
Reputation: 1495
you havent mentioned the problem you are really facing with your current approach, as it happens you cannot download the file using the XMLHTTPRequest, with your current approach a download dialog should appear as a response to your ajax request because the browser will unable to understand the "application/pdf"
ContentType and will try to download the file
Upvotes: 1