title: Have jQuery submit a form to get a file download?
body: <p>I have a form that posts to a url which triggers file download.  The server is ASP.NET MVC and I write out a CSV file.</p>
  
  <p>What I want to do is have a jQuery/javascript submit the form instead of a form submit button.</p>
  
  <p>For example, I created a link and attached a handler using jQuery to submit the form:</p>
  
  <pre><code>$(function() {
      $("#mylink").click(function() {
          $("form").submit();
          return false;
      });
  });
  </code></pre>
  
  <p>I also tried serializing the form and doing an ajax post with same result.</p>
  
  <p>What I get is that the request/response happens as should, but I do not get the file download (save file) dialog.  I can verify the response by using fiddler for example.</p>
  
  <p>It's as if the response is happening out of band or something, in a parallel thread if you will, there is no one at the door.</p>
  
  <p>Can someone shed a light?
  Thanks</p>
  
  <p><strong>UPDATE</strong>
  For some reason, <code>$("form").submit()</code> does not work but I can do my validation and pre-processing, then return true, which works.</p>