cant get values printed in to a file <p>Iam trying to pass the value stored in the variable fieldCSV to file data.csv...Ive used javascript and php to do this.. I have triggered an ajax request when a value is stored in to the variable fieldCSV, bt this is nt working as the file that gets downloaded prints the php error inside it instead of csv..</p> <pre><code>$.ajax({ type: "POST", url: "/test/fileDownload.php", data: { name: fieldCSV}, }); &lt;?php $name = $_POST["name"]; header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=data.csv'); $output = fopen('php://output', 'w'); fputcsv($output, $name); ?&gt; </code></pre> <p>What am I doing wrong?</p>