title: Export CSV using jQuery AJAX call
body: <p>I have some code to export the results of a search to a CSV file:</p>
  <pre><code>$(&quot;#exportButton&quot;).click(function () {
  
      var url = &quot;/Stuff/ExportSearchResults&quot;;
      var searchInput = readInput();
  
      $.post(url, searchInput, function (data) {
          // This is where I'm clueless.
          // I'm getting data back but not sure how to make the
          // browser show a prompt to download the file.
          console.log(data);
      });
  });
  </code></pre>
  <p>At the server side (ASP.NET MVC 4) there's this:</p>
  <pre><code>[HttpPost]
  public FileResult ExportSearchResults(SearchInput model)
  {
      string csv = GenerateCsv(model);
      return File(new UTF8Encoding().GetBytes(csv), &quot;text/csv&quot;, &quot;Export.csv&quot;);
  }
  </code></pre>
  <p>So the good thing is that I'm getting data back in the console. I'm just not sure how I would make the browser show a prompt to download a file.</p>