Blogger Information
Blog 250
fans 3
comment 0
visits 321544
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS-基本的Ajax验证表单
梁凯达的博客
Original
836 people have browsed it

实例

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>Document</title>
</head>
<body>
	Name:<input type="text" name="" id="" value=""  onblur="check(this)"/><font></font>
</body>
<script type="text/javascript">
	function check(obj){
		//alert(obj);
		//获取Input输入的值
		var name = obj.value;
		var ajax = new XMLHttpRequest();
		ajax.open('get','./get.php?name='+name,true);
		ajax.send();
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4 && ajax.status ==200){
				var result = ajax.responseText;
				if(result == 0){
					obj.nextSibling.innerHTML = '<img src="./cou.png">已经注册';
					obj.nextSibling.color = 'red';
				}else{
					obj.nextSibling.innerHTML ='<img src="./dui.png">';
					obj.nextSibling.color = 'green';
				}
			}
		}
	}
</script>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post