我主要要实现提交表单后仍然保留表单的数据,买了本《浅入深学 php》,里面 395页的代码有个 handle_f, 我照抄,但是我的PHP里没执行,为什么?我这里稍为改了一下,但是PHP 没执行handle_f,如果执行会弹出一个对话框 'hello world'<script language="javascript">var xmlHttp;
xmlHttp=create_obj();function create_obj()
{
var xmlHttp;
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;
}function process()
{
name=document.getElementById("clinametext").value;
xmlHttp.open("GET","checkcliname.php?name="+name,true);
alert("hello world");
xmlHttp.onreadystatechange=handle_f;
xmlHttp.send(null);
}function handle_f()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
alert("hello world");
result=xmlHttp.responseText;
c=document.getElementById("message");
c.innerHTML="<b>"+result+"</b>";
}
else
{
alert("执行过程中出现问题,服务器返回:"+xmlHttp.statusText);
}
}
}</script>
xmlHttp=create_obj();function create_obj()
{
var xmlHttp;
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;
}function process()
{
name=document.getElementById("clinametext").value;
xmlHttp.open("GET","checkcliname.php?name="+name,true);
alert("hello world");
xmlHttp.onreadystatechange=handle_f;
xmlHttp.send(null);
}function handle_f()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
alert("hello world");
result=xmlHttp.responseText;
c=document.getElementById("message");
c.innerHTML="<b>"+result+"</b>";
}
else
{
alert("执行过程中出现问题,服务器返回:"+xmlHttp.statusText);
}
}
}</script>
解决方案 »
- 用生成静态页面的函数php2html的问题
- Warning: array_key_exists() [function.array-key-exists]: The second argument sho
- 关于如何在IE右键菜单里面增加菜单项的问题
- 关于select
- 二维数组,行与行之间的计算,求函数
- 高手请进,在register_globals off后,无法传递类变量
- 自增长的 id 大家是怎么设的?
- 请教一个ftp的问题
- ThinkPHP 3.2.2该如何调用自定义函数库。(新手求助)
- PHP怎么写邀请码接口,从没接触过接口不知如何下手!
- apache+fastcgi+php模式,怎样实现socket长连接,象mysql_pconnect函数这样
- 求解:数据插入不到数据库中。
var xmlHttp;
if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest();
else if (window.ActiveXObject) xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;
}http://www.w3school.com.cn/xml/xml_http.asp
xmlHttp=window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
if($_POST){
$name = $_POST['name'];
}
?> <form action="test8.php" method="post">
<input type="text" name="name" value="<?=(empty($name))?"":$name?>"/>
<input type="submit" name="btn" value="submit"/>
</form>