title: how to export csv file with filename
body: <p>I want to export the exist data into csv file. I try to use this code:</p>
  
  <pre><code>var uriContent = "data:text/csv;charset=utf-8," + encodeURIComponent(data);
  var myWindow = window.open(uriContent);
  myWindow.focus();
  </code></pre>
  
  <p>it works but I can design filename. I can only get the dialog with name like "MVeAnkW8.csv.part" which I don't know where the name come from.</p>
  
  <p>How can I assign filename in the first dialog? Thanks in advance.</p>
  
  <p><strong>update:</strong></p>
  
  <p>I am now using rails. Actually I have a method in server side names export_to_csv. In end of this method, I use code like that:</p>
  
  <pre><code>  send_data(csv_string,
    :type =&gt; 'text/csv; charset=utf-8;',
    :filename =&gt; "myfile.csv")
  </code></pre>
  
  <p>It works and I can specify the file name.
  For now, I want to use ajax to get more csv files(that is the reason why I want to use javascript, because a normal http request can only get one file to be downloaded).</p>
  
  <p>I use js code like that:</p>
  
  <pre><code>$.post("export_to_csv",
   function(data) {
   var uriContent = "data:text/csv;charset=utf-8," + encodeURIComponent(data);
       var myWindow = window.open(uriContent);
       myWindow.focus();});     
  </code></pre>
  
  <p>It get the data from server side and I try to transfer it into csv. I can get a file but can't specify the file name.</p>