Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6832523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:52:08+00:00 2026-05-26T22:52:08+00:00

My problem is that I send to client first PDF to download, then I

  • 0

My problem is that I send to client first PDF to download, then I need to check, if some data exists in my database, then depending on that check I need to show question that if user want to download another PDF, that I generates.

My Code:

 //Here I just make dialog for question
 $('#printDWInfo').dialog({
            resizable: false,
            modal: true,
            autoOpen: false
        });

 //Here is my problem :)
 $('#generujWydruk').click(function (event) {
            event.preventDefault();
            $('#printForm').submit(); // <-- sending first request and client get first PFD file
            $.post('<%: ResolveUrl("~/Reports/KPiRReportDWCheck") %>', <-- check for another data
                $("#printForm").serialize(),
                function(data) {
                    if (data.length > 0) {
                        $("#printDWInfo").dialog( "option", "buttons", [
                            {
                                text: "Tak",
                                click: function () {
                                    $.ajax({ type: "POST",
                                        url: '<%= Url.Action("PrintDWList","Reports")%>',
                                        datatype: "json",
                                        traditional: true,
                                        data:{'ids': data },
                                        success: function (data2) {
                                            //I don't know what to do here
                                        }
                                    });
                                    $(this).dialog("close");
                                    }
                                }, {
                                text: "Nie",
                                click: function () {
                                    $(this).dialog("close");
                                    }
                            }
                        ]);
                        $('#printDWInfo').dialog("open");
                    }
                }
            );

If client click on button “Tak” in dialog, I use ajax request, because I can pass to controler array of int, that is returned by $.post('<%: ResolveUrl("~/Reports/KPiRReportDWCheck") %>'.
In success function of my ajax request FireBug show me that data2 is binary data of my PDF file, what I need to do to allow client to download this PDF file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:52:09+00:00Added an answer on May 26, 2026 at 10:52 pm

    In success function of my ajax request FireBug show me that data2 is
    binary data of my PDF file, what I need to do to allow client to
    download this PDF file?

    You should not use AJAX to download files. The problem is that you are fetching the pdf bytes in a javascript variable in the success callback of your AJAX call but there’s nothing you could do with it. You cannot prompt the user to save it and of course you cannot save it to the client since javascript doesn’t have the necessary privileges.

    So you should use a normal request:

    var downloadUrl = '<%= Url.Action("PrintDWList", "Reports")%>?' + $.param({ ids: data }, true);
    window.location.href = downloadUrl;
    

    Notice that this will send a GET request to the PrintDWList action passing the ids query string parameter so make sure this action is accessible on GET. Now if the controller action uses the Content-Disposition header to attachment it will offer the user to download the file:

    public ActionResult PrintDWList(int[] ids)
    {
        byte[] pdf = ...
        return File(pdf, "application/pdf", "file.pdf");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a problem updating objects with the ADO.NET Data Services. First I've create a
I'm trying to send data from client-side to server-side (asp.net c#), if you really
First, we use .net & sql server. I have a client that is interested
I'm using Apache Commons HttpClient to grab some data from a server. My problem
I need to be able to send an email from a silverlight client-side application.
I have the following code for an echo client that sends data to an
Wanting to implement authentication by client certificates I am experiencing some issues. First some
Simple problem that I can't figure out... How can I print a '%' character
The problem that I have is somehow very specific. I have to implement a
I have a strange problem that is only happening in a single location. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.