title: jQuery Ajax: pdf response
body: <p>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?</p>
  
  <p>My ajax call:</p>
  
  <pre><code>$('#sf_getpdf').click(function() {
  
   $.ajax({    //create an ajax request to load_page.php
  
          type: "POST",
  
          url: "index.php?route=sale/order/superfaktura_getpdf&amp;token=&lt;?php echo $token; ?&gt;",
  
          data: 'invoice_id=&lt;?php echo $invoice_id; ?&gt;&amp;sf_token=&lt;?php echo $sf_token ?&gt;',  //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)
              }
  
          }
  
      });
  
  });
  </code></pre>
  
  <p>Firebug, response:
  <img src="https://i.stack.imgur.com/HhhcV.png" alt="Firebug"></p>
  
  <p>Response in browser...</p>
  
  <p><img src="https://i.stack.imgur.com/NGJ07.png" alt="response in browser"></p>
  
  <p>I already tried to set content-type in server, without success:</p>
  
  <p><img src="https://i.stack.imgur.com/oTw0S.png" alt="content-type in server"></p>
  
  <p>Edit: The Ajax is not needed, to do this. </p>
  
  <pre><code>&lt;a id="adr_stitok" target="_blank" href="index.php?route=sale/order/superfaktura_getpdf&amp;token=&lt;?php echo $token; ?&gt;&amp;invoice_id=&lt;?php echo $invoice_id; ?&gt;&amp;sf_token=&lt;?php echo $sf_token ?&gt;" &gt;Download&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>Will do the thing. </p>