Bootstrap+angulerjs实现异步登陆
前端  /  管理员 发布于 5年前   410
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"}
博主 在
2023年国务院办公厅春节放假通知:1月21日起休7天中评论 @ xiaoB 你只管努力,剩下的叫给天意;天若有情天亦老,..xiaoB 在
2023年国务院办公厅春节放假通知:1月21日起休7天中评论 会不会春节放假后又阳一次?..BUG4 在
你翻墙过吗?国内使用vpn翻墙可能会被网警抓,你需了解的事中评论 不是吧?..博主 在
go语言+beego框架中获取get,post请求的所有参数中评论 @ t1 直接在router.go文件中配就ok..Jade 在
如何在MySQL查询中获得当月记录中评论 Dear zongscan.com team, We can skyroc..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号