HTML
<li><a href="javascript:void(0)" id="downloadCsv" class="userFunctionsButton">Download CSV</a></li>
JS
$(function(){
$('#downloadCsv').click(function(){
var myChart = FusionCharts('myChartId3');
var data = myChart.getDataAsCSV();
data = data.replace(/"/g, '').replace(/\n/g, 'BREAK');
var url = PATH +'dashboard/getCsvReport/?'+ encodeURIComponent( data );
window.location = url;
});
});
PHP
function getCsvReport($chart_data){
$filename = 'chart';
$data = str_replace('/', "\n", $chart_data);
header("Content-type: application/force-download");
header("Pragma: no-cache");
header("Expires: 0");
header("Content-Disposition: attachment; filename=\"".$filename.".csv\"");
$this->layout = 'empty';
$this->render('/ajax/empty');
echo $data;
}
The above only writes the first key value pair to the csv file. Turning on the AllowEncodedSlashes in the apache config is not an option.
Any ideas? References for sending post data as a form submission or ajax request.
Thank you in advance.
-a
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment