in reply to Run a perl script and return results using AJAX without reloading the page

This may not solve your problem but as you are returning JSON you need to set that in the header, so instead of:
print "Content-type: text/html\n\n";
Try:
print "Content-type: application/json\n\n";
Also, you should really get the value of the query string by creating a new CGI object, so your script would be something like this:
#!/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;
Update:
You probably need to modify your Javascript function too:
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");} }); };