如何在登录成功时显示警报

编程入门 行业动态 更新时间:2024-10-26 20:33:33
本文介绍了如何在登录成功时显示警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

index.php

index.php

<html> <script src="ajax.googleapis/ajax/libs/angularjs/1.2.8/angular.min.js"></script> <script src="cdnjs.cloudflare/ajax/libs/angular-ui-bootstrap/0.9.0/ui-bootstrap-tpls.min.js"></script> <script src="js/script.js"></script> <div id="container" ng-app="myApp"> <section> <form class="form-inline" ng-controller="FormController" ng-submit="submitForm()" role="form" method="post"> <div class="form-group"> <label class="sr-only" for="Source Station">Insert Your Name</label> <input type="text" ng-model="username" placeholder="John" class="form-control" > </div> <div class="form-group"> <label class="sr-only" for="Source Station">Insert Your City</label> <input type="text" ng-model="password" placeholder="Perth" class="form-control" > </div> <button type="submit" class="btn btn-primary">Submit Record</button> </form> </section> </div> </html>

script.js

script.js

var App = angular.module('myApp', ['ui.bootstrap']);  function FormController($scope, $http) {  $scope.submitForm = function ()  {  console.log("posting data....");  $http({   method: 'POST',  url: 'authenticate.php', headers: {'Content-Type': 'application/json'}, /*headers : {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},*/ data: JSON.stringify({username: $scope.username,password:$scope.password})  }).success(function (data){  alert(data);   console.log(data);   $scope.message = data.status; alert(data); alert($scope.message); alert(data.status); alert(data.result);   }).error(function(err){alert('aaaaa');})   };   }

authenticate.php

And authenticate.php

function ob_file_callback($buffer) { global $ob_file; fwrite($ob_file,$buffer); } $ob_file = fopen('test.txt','w'); ob_start('ob_file_callback'); $postd = file_get_contents('php://input'); $request = json_decode($postd); //print_r($request); $username = $request->username; $password = $request->password; //echo($username); //echo($password); if( $username=="service" && $password == "service@123" ) { //echo $result = "{'status':'1'}"; echo $result=1; } else { //echo $result = '{"status":"2"}'; echo $result=2; } echo json_encode($result); //$name= $request->name; //$city= $request->city; //echo json_encode($name); //print_r ($name); //print_r ($city); /*//$postdata = file_get_contents('php://input');    //  $request = json_decode($postdata);     //  $name = $postdata->name;      // $city = $postdata->city; //Parse error: in C:\xampp\htdocs\newaj\login.php on line 17<br /> //echo $name; */ ?>

推荐答案

范围,

http){ http) {  

scope.submitForm = function () { console.log( 发布数据....); scope.submitForm = function ()  {  console.log("posting data....");  

更多推荐

如何在登录成功时显示警报

本文发布于:2023-11-27 20:37:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639515.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!