Apache2 CGI Demo

Source: Internet
Author: User

1. Modify the httpd.conf configuration

<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. Test code

Index.html

<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>
<body>
<form>
</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>

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);
}
});
});
});

Push in Test.cpp

The generated test.cgi is placed under/usr/local/apache2/cgi-bin/

Apache2 CGI Demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.