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

报告相同问题?

悬赏问题

  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图