<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>登录</title>
<script type="text/javascript" src="http://cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
帐号:<input type="text" id="account" />
<br><br>
密码:<input type="password" id="password" />
<br />
<input type="button" value="登录" id="btnlogin" />
<script type="text/javascript">
$(function(){
$("#btnlogin").click(function(){
$.ajax({
type:"post",
url:"ajax.php",
data:{account:$("#account").val(),password:$("#password").val()},
dataType:"json",
success:function(data){
if(data.type==1){
alert("登录成功");
}else{
alert("登录失败");
}
},
error:function(){
alert("请求异常");
}
});
});
});
</script>
</body>
</html>
|