passing the output from a js file to another php file
<p>I have an output from a javascript file in the format</p>

<p>and the js files look like </p>

<pre><code>$(document).ready(function()
{
$.ajax({
type: "POST",
url: "test.php",
data: { name: "term", location: "Boston" }
}).done(function( msg ) {
 alert( "Data Saved: " + msg );
 });
  });
</code></pre>

<p>I want to output these values in a separate excel file.. So Ive used php and wrote a script in to another file </p>

<pre><code>&lt;?php
$name = $_POST["name"];
$location = $_POST["location"];
&lt;?php
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv'); 
$output = fopen('php://output', 'w');
fputcsv($output, array('Type', 'Entity Name', 'Link'));
fputcsv($output, results);
?&gt;
</code></pre>

<p>and included the javascript file inside the header part of php file.. bt I dont get the "result" output generated by the js file. 
How can I pass the result from js file to php file?</p>
