zoukankan      html  css  js  c++  java
  • Apache2 CGI demo

    1. 修改 httpd.conf  配置

    <IfModule alias_module>

     ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

    </IfModule>

    。。

    <Directory "/usr/local/apache2/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

    2. 测试代码

    index.html

    <html>
            <head>
                    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
                    <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
                    <script type="text/javascript" src="js/test.js"></script>
            </head>
            <body>
                    <form>
                            <h1>Hello Apache!</h1>
                    </form>
                    <form>
                            <p>Get<br>
                            Value: <input id="getValue" disabled="true"><br>
                            <input type="button" id="get_value" Value="Get">
                    </form>
                    <form>
                            <p>Put<br>
                            Value: <input id="postValue"><br>
                            <input type="button" id="post_value" Value="Post">
                    </form>
            </body>
    </html>

    test.js

    $(document).ready(function(){
                    $("#post_value").click(function(){
                            $.ajax({
                                            type: "post",
                                            url: "cgi-bin/test.cgi",
                                            contentType: "text",
                                            dataType: "text",
                                            data:"value="+$("#postValue").val(),
                                            error: function(result) {
                                                    alert("error: get data fail");
                                            },
                                            success: function(result) {
                                                    $("#getValue").val(result);
                                            }
                            });
                    });

                    $("#get_value").click(function(){
                            $.ajax({
                                            type: "get",
                                            url: "cgi-bin/test.cgi",
                                            dataType: "",
                                            data: "value",
                                            error: function(result) {
                                                    alert("error: get data  fail");
                                            },
                                            success: function(result) {
                                                    $("#getValue").val(result);
                                            }
                            });
                    });
    });

    test.cpp  中进行推送

    生成的test.cgi 放于 /usr/local/apache2/cgi-bin/ 下

  • 相关阅读:
    Animate.css 一款强大的预设css3动画库
    关于js返回上一页的实现方法
    jquery判断字符串中是否包含特定字符的方法总结
    去掉select在苹果手机上的原生样式
    html5中如何去掉input type date默认样式
    JS和jQuery中ul li遍历获取对应的下角标
    滚动一定的高度底色递增
    喵哈哈村的狼人杀大战(5)
    喵哈哈村的狼人杀大战(2)
    One Card Poker
  • 原文地址:https://www.cnblogs.com/maxpak/p/4704512.html
Copyright © 2011-2022 走看看