1,ajax(asynchronouse javascript and xml)异步的 javascrip 和xml
2,(包含了7种技术:javascript xml xstl dom xhtml css xmlhttpRequest)
3,是一种与服务器语言无关的技术,可以用在(php/jsp/asp.net)
4,ajax的工作原理: 创建一个ajax引擎->发送数据给服务器--》通过回调函数接收数据---》将数据赋给指定的页面
下面是注册验证案例register。php是注册页面。registerProcess.php用于接收数据并返回数据
register.php
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>用户注册</title>
<>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<>
<script type="text/javascript">
<>
</script>
</head>
<body>
<form action="???" method="post">
用户名字:<input type="text" name="username1" id="username" ><input type="button" value="验证用户名">
<input type="text" id="myres" />
<br/>
用户密码:<input type="password" name="password"><br>
电子邮件:<input type="text" name="email"><br/>
<input type="submit" value="用户注册">
</form>
<form action="???" method="post">
用户名字:<input type="text" name="username2" >
<br/>
用户密码:<input type="password" name="password"><br>
电子邮件:<input type="text" name="email"><br/>
<input type="submit" value="用户注册">
</form>
</body>
</html>
regiseterProcess.php
复制代码 代码如下:
<?php
$username=$_REQUEST['username'];
if($username=="shunping"){
echo "err";
}else{
echo "ok";
}
?>