I have an output from a javascript file in the format
and the js files look like
$(document).ready(function()
{
$.ajax({
type: "POST",
url: "test.php",
data: { name: "term", location: "Boston" }
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
});
I want to output these values in a separate excel file.. So Ive used php and wrote a script in to another file
<?php
$name = $_POST["name"];
$location = $_POST["location"];
<?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);
?>
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?