Click here to Skip to main content
15,887,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I did a ajax call using jquery to a handler. In the handler's response I write the context type and save a pdf file. Now in the jquery I have to open the pdf file. I used jquery file download plugin. But it doesn't work for me. Plz help me, to complete this task.

JQuery:

JavaScript
function CallHandler() {
                $.ajax({
            url: "iss_report.ashx",
            contentType: "application/json; charset=utf-8",
            success: OnComplete,
            error: OnFail
        });
        return false;
    }
    function OnComplete(result) {
           $.fileDownload(result);
    }
    function OnFail(result) {
        alert('Request failed');
    }

In handler:
C#
public class iss_report : IHttpHandler {
    public iss_report()
    {
    }

    public void ProcessRequest (HttpContext context) {
  Workbook wb= new Workbook();

        context.Response.SetCookie(new HttpCookie("fileDownload", "true") { Path = "/" });
        context.Response.ContentType = "application/pdf";
        invoicebook.Save(context.Response, "mybook.pdf", ContentDisposition.Attachment, new PdfSaveOptions());
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
Posted
Updated 14-Nov-12 17:03pm
v3
Comments
fjdiewornncalwe 14-Nov-12 8:43am    
Why did you tag your question C++. C++ is a whole different ball of wax from C#.
Sergey Alexandrovich Kryukov 14-Nov-12 23:06pm    
Tag: ASP.NET, C#, jQuery
--SA
n.podbielski 15-Nov-12 3:46am    
Do not work? Are there some errors?
Sam Jenifa 15-Nov-12 4:39am    
Thanks for your reply.
Ya, it doesn't work.File download error occurs. How to resolve it?? plz help me.
n.podbielski 15-Nov-12 5:24am    
What error ? Can you be more specific?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900