title: AJAX return file created with php script
body: <p>I'm trying to implement excel export function for my table. I'm sending form data with ajax and php script creates file with this data and then nothing. I want ajax return the file created with php. Here is my code.</p>
  
  <pre><code>$('body').on('click', '#excel', function() {        
      var veri = $('form[method="get"]').serializeArray();
      veri['action'] = 'userexcel';
      jQuery.ajax({
             type: "POST",
             url: &lt;?php echo '"' . admin_url( 'admin-ajax.php' ) . '"';?&gt;,
             data: veri,
             success: function(data){
                 alert(data); 
             }
          });
      return false;
  });
  </code></pre>
  
  <p>And my php function</p>
  
  <pre><code>function exportExcel($filename='ExportExcel',$columns=array(),$data=array(),$replaceDotCol=array()){
  header('Content-Encoding: UTF-8');
  header('Content-Type: text/plain; charset=utf-8'); 
  header("Content-disposition: attachment; filename=".$filename.".xls");
  echo "\xEF\xBB\xBF"; // UTF-8 BOM
  
  $say=count($columns);
  
  echo '&lt;table border="1"&gt;&lt;tr&gt;';
  foreach($columns as $v){
      echo '&lt;th style="background-color:#FFA500"&gt;'.trim($v).'&lt;/th&gt;';
  }
  echo '&lt;/tr&gt;';
  
  foreach($data as $val){
      echo '&lt;tr&gt;';
      for($i=0; $i &lt; $say; $i++){
  
          if(in_array($i,$replaceDotCol)){
              echo '&lt;td&gt;'.str_replace('.',',',$val[$i]).'&lt;/td&gt;';
          }else{
              echo '&lt;td&gt;'.$val[$i].'&lt;/td&gt;';
          }
      }
      echo '&lt;/tr&gt;';
  }
  }
  </code></pre>