What is the best way to pass selected rows to a cgi-bin script?
What is the best way to pass selected rows to a cgi-bin script?
bigsipper
Posts: 31Questions: 2Answers: 0
I need to pass only the rows a user has selected (multiple rows at one time -sometimes up to a few hundred) to
a cgi-bin script.
The cgi-bin script will need to process the data, make some database entries, send emails, etc....
What is the best way for me to deliver the selected data to the cgi-bin?
Should I build a form with a hidden 'data' field and POST it to the url of the cgi-bin script?
I don't think a GET method would work....
-Bigsipper
a cgi-bin script.
The cgi-bin script will need to process the data, make some database entries, send emails, etc....
What is the best way for me to deliver the selected data to the cgi-bin?
Should I build a form with a hidden 'data' field and POST it to the url of the cgi-bin script?
I don't think a GET method would work....
-Bigsipper
This discussion has been closed.
Replies
The answer I came upon is that the selected data object can be passed like any other object
in javascript:
client side code:
[code]
var oTT = TableTools.fnGetInstance( 'table' );
var aData = oTT.fnGetSelectedData();
$.post('cgi-bin/notify.cgi',{recompid: recompid, data: JSON.stringify(aData, null, 2)});
[/code]
server side code:
[code]
my $req = new CGI();
my $vars = $req->Vars();
my %params = map { $_, $vars->{$_} =~ /\0/ ? [ split /\0/, $vars->{$_} ] : $vars->{$_} } keys %$vars;
foreach my $row ( $json->decode($params{data}) ){
yada... yada...
[/code]