title: Generate PDF with AJAX request
body: <p>I'm using Laravel 5.4 and I'm trying to generate a PDF download using Snappy PDF.</p>
  
  <p>The reason I am trying to do it this is way is so that I can submit the form data to the PDF without reloading the page.</p>
  
  <p>Here is my blade template:</p>
  
  <pre><code>&lt;div&gt;
      Download a PDF: &lt;button type="button" class=" btn-success btn-sm" id="js-download" &gt;Download&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my route:</p>
  
  <pre><code>Route::get('/download', 'FormController@generatePDF');
  </code></pre>
  
  <p>This is my controller function:</p>
  
  <pre><code>public function generatePDF(Request $request)
  {
      $pdf = PDF::loadView('pdf.download', $request);
      return $pdf-&gt;download('download.pdf');
  }
  </code></pre>
  
  <p>And this is my .js file:</p>
  
  <pre><code>$(document).on("click", "#js-download", function(e) {
  
  e.preventDefault();
  
  $.ajax({
      url: '/download',
      data: $("#js-pdf-form").serialize(),
      success:function(data) {
          console.log(data)
      },
      error:function() {
      }
  });
  
  });
  </code></pre>
  
  <p>The PDF works if I call the route via the address bar in the browser, but if I click the button and attempt an AJAX request it fails, however it does console log what seems to be the PDF output...</p>
  
  <p>Any help would be greatly appreciated.</p>