Blogger Information
Blog 27
fans 2
comment 1
visits 13401
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
将$.ajax()的第一种用法 2018-4-10
kaclod的博客
Original
607 people have browsed it

实例

<!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>
	
</body>
</html>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
	//当失去焦点时候验证
	$(':input').blur(function(){
		//alert('通过')

		$.ajax({
		//请求服务器资源,必须是字符串
		url:'api/demo.php',
		//客户端请求类型:get,post
		type:'GET'

		//重服务器端返回数据类型格式,
		dataType:'json',

		//异步true 还是同步false
		async:true,
		//发送数据
		data:'name='+$(':input').val(),
		data:$('form:first').serialize(),


		//成功回调
		success:function(){
			console.log(msg)
			$('p span').empty()
			$('p').append($(msg))
		}
	})



	})
</script>

运行实例 »

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

QQ截图20180412112846.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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!