title: Storing generated PDF files on the server
body: <p>Using the <code>jsPDF</code> plugin, I am creating a <code>.pdf</code> file and generating a download based on a button click. I would like to save the file onto my server instead of initiating the download. So when the button is clicked I would like the file to be saved in : </p>
  
  <pre><code>/tmp/uploads/pdf/example.pdf
  </code></pre>
  
  <p>I am aware I need have to use <code>Jquery.Ajax</code> to post the file to the server. However, looking at the documentation and I didn't see any support for <code>.pdf</code> as a datatype.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>$(document).on("click", "#PDF", function () {
      var table = document.getElementById("result");
      var tbl = window.sessionStorage.getItem("tbl");
      var cols = [],
          data = [];
  
      function html() {
          var doc = new jsPDF('p', 'pt');
          var res = doc.autoTableHtmlToJson(table, true);
          doc.autoTable(res.columns, res.data);
          doc.save( tbl+".pdf");
      }
      html();
  });
  </code></pre>
  
  <p>Based on this <a href="http://api.jquery.com/jquery.ajax/" rel="noreferrer" title="xml example">xml document saving</a> example I tried the following:</p>
  
  <pre><code>var pdfDocument = doc.save( tbl+".pdf");
          var pdfRequest = $.ajax({
                url: "/tmp/uploads/pdf",
                processData: false,
                data: pdfDocument
              });
  </code></pre>
  
  <p>This downloaded the file instead of saving it. How can I save the file?</p>