title: PHP headers are not working in WordPress ajax call
body: <p>I have a PHP script that generate and download CSV file. Following is the code of that script:</p>
  
  <pre><code>&lt;?php
  
  $cars = array(
    array("Volvo",22,1888),
    array("BMW",15,13),
    array("Saab",5,2),
    array("Land Rover",17,15)
    );
  
  // output headers so that the file is downloaded rather than displayed
  header('Content-Type: text/csv; charset=utf-8');
  header('Content-Disposition: attachment; filename=csvfile.csv');
  
  // create a file pointer connected to the output stream
  $output = fopen('php://output', 'w');
  
  // output the column headings
  fputcsv($output, array('Car', 'Year', 'Miles' ));
  
  //Loop through the array and add to the csv
  foreach ($cars as $row) {
      fputcsv($output, $row);
  }
  exit;
  ?&gt;
  </code></pre>
  
  <p>This script work fine when I access it directly, But my aim is to use this script in a WordPress AJAX call, I have created the AJAX using WordPress AJAX API as following:</p>
  
  <pre><code>add_action( 'wp_ajax_export_timeline', 'export_timeline' );
  </code></pre>
  
  <p>And then same PHP code (that is pasted above) is written in callback function <code>export_timeline</code>, but instead of generating CSV and downloading against the AJAX call, printed array is returned in response. There is no error in AJAX in call, I have tested with echoing other string, its responding fine.</p>
  
  <p>But in case of upper mentioned script, I think PHP headers are not working in callback function, because instead of generating and downloading CSV, its echoing the array in response. Any help is appriciated.</p>