from this option of my drop down menu im trying to call javascript function gen(); my html table is 'horse_trainings' which is converted to cvs format; but it didnot download where as when i checked code on the internet it all headers were the same procedures everything matched but it didnt work.
<li><a href="#" onclick="gen();">Export In Excel</a></li>
This is my script:
<script type="text/javascript" src="http://www.kunalbabre.com/projects/table2CSV.js"> </script>
<script>
function gen()
{
var csv_value=$('#horse_trainings').table2CSV({delivery:'value'});
$.ajax({
type:"POST",
url:"trainingxls.php",
datatype:"csv/text",
data:"func=text&data="+csv_value+"",
}).done(function(t){
alert(t);
});
}
</script>
my trainingxls.php file:
<?php
if(isset($_POST["func"])){
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"my-data.csv\"");
$d=stripcslashes($_REQUEST['data']);
//echo $_POST['data'];
echo $d;
}
?>
problem: Its not downloading the cvs file on click.