Reputation: 61
I can't execute perl by ajax. Why the responseText always returns the entire perl codes?
The following example is to get data from perl. The response I get from function updateTime is the entire perl code.
BTW: I can execute the perl code in cmd window using command "c:/perl/bin/perl test.cgi".
The JS code is as below:
function updateTime(){
var xmlhttp_t = createXMLHTTPRequest();
xmlhttp_t.open("GET","cgi-bin/test.cgi",false);
xmlhttp_t.send();
if(xmlhttp_t.readyState == 4){
return xmlhttp_t.responseText;
}
}
//
//Get XMLHttpRequest
//
function createXMLHTTPRequest(){
var xhr_object = null;
if(window.XMLHttpRequest)
{
xhr_object = new XMLHttpRequest();
}
else if(window.ActiveXOject)
{
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser doesn't provide XMLHttpRequest functionality");
return;
}
return xhr_object;
}
The Perl code is as below:
#!c:/perl/bin/perl
use strict;
use CGI;
use warnings;
my $cgi = new CGI();
print $cgi->header('text/html; charset=UTF-8');
print "aaaa";
Upvotes: 0
Views: 301
Reputation: 385897
The response I get from function updateTime is the entire perl code.
Then it's a server configuration issue.
Upvotes: 3