侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

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"}



  • 上一条:
    oracle 11g 在linux6 安装环境配置
    下一条:
    oracle中表空间和数据文件
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • jq中实现图片压缩、base64转成file后上传至服务器示例(0个评论)
    • 在JavaScript中实现批量下载OSS中的文件代码示例(0个评论)
    • 如何优雅处理async await错误推荐:await-to-js库(0个评论)
    • lodash工具库(0个评论)
    • nginx + vue配置实现同域名下不同路径访问不同项目(0个评论)
    • 近期文章
    • 在go语言中对Grpc工具buf.build使用流程步骤(0个评论)
    • 宝塔面板Nginx开启Brotli压缩流程步骤,提升网站加载速度(0个评论)
    • 在go语言中如何判断用户代理是否为移动设备的示例(0个评论)
    • 在go语言中实现一个函数来检查用户代理是否是机器人或爬虫的示例(0个评论)
    • Laravel 10.13版本发布(0个评论)
    • 在github创建task的同时创建分支流程步骤(0个评论)
    • 在go语言中以邮件标题中获取SPF和DMARC,来判断是否为垃圾邮件之垃圾邮件过滤器功能实现(0个评论)
    • 在go语言中使用attr字段标签提取XML属性数据示例(0个评论)
    • 在laravel中介绍一个生成假数据的PHP库:FakerPHP(0个评论)
    • 在laravel框架中对环境配置文件的加载过程步骤浅析(0个评论)
    • 近期评论
    • 博主 在

      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..
    • 2016-11
    • 2017-06
    • 2017-07
    • 2017-08
    • 2017-09
    • 2017-10
    • 2017-11
    • 2018-03
    • 2018-04
    • 2018-05
    • 2018-06
    • 2018-09
    • 2018-11
    • 2018-12
    • 2019-02
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2021-04
    • 2021-05
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客