print "Content-type: text/html\n\n"; #### print "Content-type: application/json\n\n"; #### #!/usr/bin/perl use strict; use warnings; use JSON; use CGI; my $cgi = CGI->new(); my $string = $cgi->param('s'); my $json = encode_json( [$string] ); print $cgi->header( -type => 'application/json' ); print $json; #### function perlExecute(term){ $.ajax({ type: 'POST', url: '/cgi-bin/doma.pl', data: { 's': term }, success: function(res) { alert(res); }, error: function() {alert("did not work");} }); };