weixin_33670713 2016-12-08 22:24 采纳率: 0%
浏览 134

CGI脚本问题

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.

  • 写回答

1条回答 默认 最新

  • weixin_33709219 2016-12-09 09:57
    关注

    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"
    
    评论

报告相同问题?

悬赏问题

  • ¥15 对法兰连接元件所承受的表面载荷等效转化为法兰开孔接触面上的等效表面载荷?
  • ¥15 comsol仿真压阻传感器
  • ¥15 Python线性规划函数optimize.linprog求解为整数
  • ¥15 llama3中文版微调
  • ¥15 在win系统Django虚拟环境下载mysqlclient报错
  • ¥15 pg数据库导入数据序列重复
  • ¥15 三分类机器学习模型可视化分析
  • ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)
  • ¥50 Qt在release捕获异常并跟踪堆栈(有Demo,跑一下环境再回答)
  • ¥30 python,LLM 文本提炼