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

  • SEARCH
  • Home
  • 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 7975471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:38:54+00:00 2026-06-04T08:38:54+00:00

I have a link and when user click on it, then he get a

  • 0

I have a link and when user click on it, then he get a PDF. In jQuery, I create a POST ajax call to the server to get the PDF. The response is a PDF, with correct content headers etc that would normally cause the browser to open the Reader plugin, or allow the user to save the PDF. But in my case, this is not working. Is there any way to set data content type, or set content type to PDF?

My ajax call:

$('#sf_getpdf').click(function() {

 $.ajax({    //create an ajax request to load_page.php

        type: "POST",

        url: "index.php?route=sale/order/superfaktura_getpdf&token=<?php echo $token; ?>",

        data: 'invoice_id=<?php echo $invoice_id; ?>&sf_token=<?php echo $sf_token ?>',  //with the page number as a parameter

        dataType: "text",   //expect html to be returned


        success: function(msg){



            if(parseInt(msg)!=0)    //if no errors

            {

            document.write(msg)
            }

        }

    });

});

Firebug, response:
Firebug

Response in browser…

response in browser

I already tried to set content-type in server, without success:

content-type in server

Edit: The Ajax is not needed, to do this.

<a id="adr_stitok" target="_blank" href="index.php?route=sale/order/superfaktura_getpdf&token=<?php echo $token; ?>&invoice_id=<?php echo $invoice_id; ?>&sf_token=<?php echo $sf_token ?>" >Download</a></td>

Will do the thing.

  • 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-06-04T08:38:55+00:00Added an answer on June 4, 2026 at 8:38 am

    Be sure your server side returns a downloadeable content and make a submit to the file, something like:

                //$.download('path', 'data' [, 'post'])
                $.download = function(url, data, method) {
                    //url and data options required
                    if(url && data) {
                        var form = $('<form />', { action: url, method: (method || 'get') });
                        $.each(data, function(key, value) {
                            var input = $('<input />', {
                                type: 'hidden',
                                name: key,
                                value: value
                            }).appendTo(form);
                        });
                    return form.appendTo('body').submit().remove();
                    }
                throw new Error('$.download(url, data) - url or data invalid');
                };
    
    $.download("index.php?route=sale/order/superfaktura_getpdf&token=<?php echo $token; ?>", {}, 'post')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose, I want to have a link or a button that when user click
i have created Array of Linkbutton and when user click on link button it
hi i have a page contains a link , when user click the link
i have a page , with a link , if the user click the
I have this url for example: http://example.com?parameter=content When the user click in this link,
I am using jquery so that when the user clicks a link I get
What I want to do: Have the user click a link, it goes to
I have noticed when user clicks on a link with, say middle button, or
I have a web app where if a user clicks on a link it
I have the following script that runs when a user clicks a link that

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.