Hi
I am have a slight different problem, but still I am posting it because it is some what related to the topic. I am trying to call a perl script from a javascript which has to generate a CSV file. I even went thorugh the above posted code but it's not working for me. I am posting my code below, see if any one can help or have a solution for this.
Code:
function testCSV()
{
alert('Got the data');
new Ajax.Request(cgiPath+'testCSV.pl',
{
method: 'get',
parameters: {
action: 'createCSV',
type: 'sample',
ts: new Date().getTime()
},
onComplete: function() {
alert('Created CSV');
}
});
}
Perl Script
use CGI;
use JSON;
$cgi = new CGI();
$action = $cgi->param('action');
if ($action eq 'createCSV')
{
createCSV();
}
else
{
die 'Action not specified';
}
sub createCSV
{
print 'Content-type: application/octet-stream\n';
print 'Content-Disposition: attachment;filename=users.csv\n\n';
print ''1','Test, first one'' . '\n';
print ''2','Test, last one'' . '\n';
}
Any help will be appreciated. Thanks in advance.
Bookmarks