Blogger Information
Blog 35
fans 2
comment 0
visits 22623
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
$.ajax请求--2018年4月11日12时
小学僧的博客
Original
540 people have browsed it
  1. 代码利用$.ajax实现了无刷新的实时在线验证

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>ajax</title>
</head>
<body>	
	<form style="width: 450px">
		<fieldset>
			<legend><h2>login</h2></legend>
			<p>name:<input type="text" name="name"></p>
		</fieldset>		
	</form>
</body>
</html>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
	$(':input').on('input',function(){
		$.ajax({			
			url:'login.php',
			type :'POST',
			// dataType:'jsonp',
			async:'true',
			data:$('form:first').serializeArray(),
			success:function(msg,status,xhr){
				// console.log(msg)
				$('p span').remove()
				$(msg).appendTo('p')
			}
		})
	})
</script>

运行实例 »

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

总结:$.ajax(url,type,data,dataType,success,error) 请求加载远程数据

Correction status:qualified

Teacher's comments:
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