Reputation:
A user has to type some text into a text field which is declared as a form in my HTML. Some JavaScript code prints the user's input which has been processed by a CGI script.
function xmlHttpPost(strURL) {var xmlHttpReq;
// Mozilla/Safari
if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open('POST', strURL, true);
xmlHttpReq.timeout = 0;
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form- urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4) {
updatepage(xmlHttpReq.responseText);
}
}
var form = document.forms['f1'];
var query = form.word.value;
xmlHttpReq.send("key=" + query);
}
function updatepage(str){
document.getElementById("result").innerHTML = "Result:" + "<br/>" + str;
}
#!"G:\xampp\perl\bin\perl.exe"
use CGI;
$query = new CGI;
$key = $query->param('key');
print $query->header;
print "<h1>The key is $key</h1>"
When I type something into the form and submit the data Error 500 occurs:
End of script output before headers: ajax-echo.cgi
This is what Apache's error.log says
AH01215: Can't locate CGI.pm in @INC (@INC contains: .) at G:/xampp/cgi-bin/ajax-echo.cgi line 7.\r, referer: http://localhost/ajax.html?word=test
AH01215: BEGIN failed--compilation aborted at G:/xampp/cgi-bin/ajax-echo.cgi line 7.\r, referer: http://localhost/ajax.html?word=test
There's a newly installed and configured XAMPP installation on my USB stick. It has every permission it needs to run properly.
Upvotes: 1
Views: 406
Reputation: 2360
The important part of the error message is this:
Can't locate CGI.pm in @INC (@INC contains: .)
The search path for modules just contains the current directory "." and obviously there is no CGI.pm in the current directory.
Try to find the directory, where CGI.pm is installed, and then add this line to your Apache configuration
SetEnv PERL5LIB "G:/xampp/path/to/module/directory"
Upvotes: 1