This is a very small problem , but it bother me for a long time.
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>7bit</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="./css/com.css">
<script type="text/javascript" src= "./js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="./js/jquery.mousewheel.js"></script>
<script src="./js/jquery.loadthumb.js" type="text/javascript"></script>
<script type="text/javascript" src= "tip.js"></script>
</head>
<body>
<div id="scroll" ><ul></ul></div>
<div id="scroll-title"><ul></ul></div>
<div class="say"><p class="state"></p></div>
<div id="call"> </div>
<div id = "alk"></div>
<div id="fox">
<form class="searchform" >
<input class="searchfield" type="text" value="" onkeydown="if(event.keyCode==13){return false;}">
<input class="searchbutton" id= "txt" type="button" value="T">
<!input class="searchbutton" id= "ImgSearch" type="button" value="I">
</form>
</div>
<div id="msg_controls" class="msg_controls">
<a href="#" id="msg_pause_play" class="msg_pause"></a>
</div>
<div id="ajax">
</div>
</body>
</html>
Ans.cpp
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
using namespace std;
int main(int arc, char* arv[])
{
ifstream ifs("Cat");
if (!ifs) {
cerr << " Error.../AnsMe.cpp ;" << endl;
cout << " Error.../AnsMe.cpp ;" << endl;
}
cout << "<br>This is a test;" << endl;
string strLine = "<br>obstacle; stumbling block; a tiger blocking the way ...; hindrance; it is a master at blocking progress ;";
cout << strLine << endl;
while (getline(ifs, strLine)) {
cout << strLine << endl;
}
ifs.close();
cout << "<br>I still don't know what had happened until now ..; " << endl;
return(0);
}
tip.js
$(function(){
function txtload(nam){
$("#call").load("mac.php",nam);
};
$('.searchform #txt').click(function(){
var nam = $(".searchfield").val();
if(nam.length<1){
return false;
}
nam = "searchterm=" + nam;
txtload(nam);
});
});
mac.php
<?php
header("Content-Type:text/html;charset=GB2312");
if ($_POST) {
$searchterm=$_POST['searchterm'];
} else {
$searchterm=$_GET['searchterm'];
}
$searchterm=iconv("UTF-8","gb2312",$searchterm);
$retid = 0;
$searchterm= trim($searchterm);
if(!$searchterm);
else if(!get_magic_quotes_gpc())
$searchterm=addslashes($searchterm);
$search = '0';
$term = $search.$searchterm;
$terf=strlen($term);
if($terf>128);
else
passthru("./Ans $term",$retid);
if(!$searchterm){
echo '<p style="margin-left: 96px;">Please keep your input inclide information ..</p>';
}else if($terf>128){
echo '<p style="margin-left: 96px;">Too large your ask sentance ..</p>';
}else if($retid){
echo '<p style="margin-left: 96px;">Sorry to say the Server gave no answer to you ..</p>';
}
?>
这时运行是正常的。
但是,如果将Ans & php 等放在不同的子目录,就不行了。