Blogger Information
Blog 59
fans 0
comment 1
visits 48013
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
$.ajax()方法——2018年4月11日23时32分
白猫警长的博客
Original
462 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>0410会员登录</title>
	<style>
		.box{
			width: 400px;
			height: 300px; 
			border: 1px solid #666;
			background-color: lightblue;
			margin: auto;
			padding: 10px;
		}
	</style>
</head>
<body>
	<div class="box">
		<h2>会员登录</h2>
		<form action="api/check.php" method="post">
			<p class="ops">
			<label for="name">邮箱:</label>
			<input type="email" name="name" id="email">
			</p>
			<p>
			<label for="password">密码:</label>
			<input type="password" name="password" id="password">
			</p>
			<p>
				<button>登录</button>
				<span id="tips"></span>
			</p>
		</form>
	</div>
</body>
</html>
 <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> 
 <script>
 	$(':input').blur( function(){

 		$.ajax({
 			// 请求服务器资源,必须是字符串
 			url:'api/demo.php',

 			// 客户端的请求类型:GET,POST
 			type:'GET',

 			data:$('form:first').serializeArray(),

 			success:function(msg,status,xhr){
 				// console.log(msg)
 				$('p span').empty()
 				$('.ops').append($(msg))
 			}
 		})

 	})

 </script>

运行实例 »

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


运行效果 图:

22.png


手抄作业:

1.jpg2.jpg

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