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.
JavaScript
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;
}
CGI
#!"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., referer: http://localhost/ajax.html?word=test
AH01215: BEGIN failed--compilation aborted at G:/xampp/cgi-bin/ajax-echo.cgi line 7., 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.