in reply to Run a perl script and return results using AJAX without reloading the page
Try:print "Content-type: text/html\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:print "Content-type: application/json\n\n";
Update:#!/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");} }); };
|
|---|