本文为
H5EDU
机构官方
HTML5培训
教程,主要介绍:
JavaScript强化教程
——AJAX
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text" id="myend">
<script>
var pv = document.getElementById("myend");
var xmlhttp = null;
pv.onblur = function(){
if(window.ActiveXObject){//表明是IE
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else {//表明是 google oprea Firefox 等浏览器
xmlhttp = new XMLHttpRequest();
}
if(xmlhttp!=null){
xmlhttp.open("get","/061902v/logoin.php?us="+pv.value,true);//异步
xmlhttp.send(null);//只用于post方式,get方式参数为null
xmlhttp.onreadystatechange = callback;//请求服务器回调
}
}
function callback(){
if(xmlhttp.readyState == 4){//表示服务器请求成功
if(xmlhttp.status ==200){//服务器返回数据
alert(xmlhttp.response);//弹出服务器返回的数据
}
}
}
</script>
</body>
</html>
简单的php文件
<?php
$name = $_GET["us"];
if($name=="wangyi"){
echo "1";
}else{
echo "0";
}
?>