0

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.

Hau Le
  • 667
  • 2
  • 17
  • 42
  • have you tried something please show the code. – Jai Nov 08 '12 at 10:23
  • 1
    Help you with what? You haven't really asked a question (the title is not sufficient). Please explain more clearly what you want to do, and why the code you've quoted doesn't do it. – T.J. Crowder Nov 08 '12 at 10:24

2 Answers2

1

You can't download files using an ajax request.

ZippyV
  • 12,540
  • 3
  • 37
  • 52
1

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

JIA
  • 1,485
  • 13
  • 11