title: JQuery file download with Ajax
body: <p>I'm using John Culviner's great fileDownload plugin to produce a "please wait" message when my user chooses to generate a report.</p>
  
  <p>When a user clicks a link, I send an ajax request to my PHP which generates a PDF on the server. At that point I am attempting to update the link in my success handler for the fileDownload plugin.</p>
  
  <p>I may be approaching this wrong, but here's my code - any help is greatly appreciated.</p>
  
  <pre><code>$("body").on("click","##pdfLink", function(e){
  
      $.fileDownload($(this).attr('href'), {
          preparingMessageHtml: "Preparing your report, please wait...",
          failMessageHtml: "There was a problem generating your report, please try again."
      });
  
      // Build our data string.
      var strData = {method: "createPDF"};
  
      // Send a request to build our XL file.
      $.ajax({
          url: '/pdf.php',
          data: strData,
          type: 'get',
          dataType: 'json',
          success: function(data) {
              alert(data);
              $("##pdfLink").attr("href","/pdf/"+data);
          },
          error: function(e) {
              console.log(e);
          }
      });
      return false; 
      e.preventDefault(); 
  })
  </code></pre>
  
  <p>At this point, when I click the link the modal is displayed correctly with the "Please Wait" message. My file does get built on the server (Confirmed with my alert in my success handler), and my HREF does get updated. However, the plugin does not prompt the user for download.</p>
  
  <p>Thanks!</p>