Bootstrap+angulerjs实现异步登陆
前端  /  管理员 发布于 7年前   773
html:
<body style="background:#fff;" ng-app="Ajax" ng-controller="Ajax">
<form>
<div class="form-group" style="margin-bottom: 5px;">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" ng-model="email" class="form-control" id="inputEmail3" />
<span id="check_user" style="font-size: 8px;color: red;display: none;"></span>
</div>
</div>
<div class="form-group" style="margin-bottom: 0px;">
<label for="inputPassword3" class="col-sm-2 control-label">Pass</label>
<div class="col-sm-10">
<input type="password" ng-model="password" class="form-control" id="inputPassword3" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox" />Remember me</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" ng-click="get_more();" class="btn btn-primary btn-large">Sign in</button>
</div>
</div>
</form>
js:
<script type="text/javascript">
var myModule = angular.module("Ajax",[]);
myModule.controller("Ajax",["$scope","$http",function Ajax($scope,$http){
$scope.get_more = function(){
$http({
method: "POST",
url: "login",
data:{'username':$scope.username,
'email':$scope.email,
'password':$scope.password
}
}).
success(function(data, status) {
//$scope.status = status;
$scope.users = data;
if (data.error == 1) {
alert(data.info);
location.reload();
}else{
$("#check_user").html(data.info);
$("#check_user").css("display","block");
};
}).
error(function(data, status) {
//$scope.data = data || "Request failed";
//$scope.status = status;
});
}
}]);
</script>
效果:(用file_get_contents("php://input")获取参数,在json_decode转)
{ email: "11", password: "1"}122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号
