title: How to force file download upon jQuery AJAX success?
body: <p>I'm generating a file dynamically in <em>php</em> like this :</p>
  
  <pre><code>$attachment_url = "http://www.mysite.com/file.jpg";
  header('Pragma: public');
  header('Expires: 0');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Cache-Control: private',false);
  header('Content-Type: application/force-download');
  header('Content-Disposition: attachment; filename="'.basename( $attachment_url ).'"');
  header('Content-Transfer-Encoding: binary');
  header('Connection: close');
  readfile( $attachment_url );
  </code></pre>
  
  <p>This data in then passed through <em>jQuery.ajax</em></p>
  
  <p>I'd like to make it open a file download dialog upon success.</p>
  
  <p>Right now I have this :</p>
  
  <pre><code>success: function(data, textStatus, XMLHttpRequest) {
      var win = window.open();
      win.document.write(data);
  }
  </code></pre>
  
  <p>This does open a new window and display the raw file data. Instead I would like a download dialog to open.</p>