Blogger Information
Blog 18
fans 0
comment 0
visits 9334
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
ajax无刷新验证---2018年4月10号
学习不刻苦 不如卖红薯
Original
458 people have browsed it

$.ajax()代码:

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>$.ajax()</title>
</head>
<body>
	<h2>用户登录</h2>
	<form>
		<p>用户名:<input type="text" name="name"/></p>
	</form>
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript">
		//1.当失去焦点时进行验证
		$(':input').blur(function(){
			//2.将全部语法写到ajax中
			$.ajax({
				url:'api/demo.php',
				type : 'GET',
				//3.将表单控件内容写到json中
				data: $('form:first').serializeArray(),
				//成功回调
				success:function(msg,status,xhr){
					console.log(msg)
					$('p span').empty()
					$('p').append($(msg))
				}
			})
		})
	</script>
</body>
</html>

运行实例 »

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

手抄作业:

1.jpg

总结:

学习了blur失去焦点的验证。1、资源路径2、类型3、序列化4、成功回调。。

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