4-3 data内容没有post上去
来源:4-4 异步方式实现登录功能—服务端对数据进行强校验
Aimeesui
2017-02-17
login.js:
//前端登录业务类 var login = { check : function (){ // var username = $('input[name="username"]').val(); var password = $('input[name="password"]').val(); if(!username){ dialog.error("用户名不能为空"); } if(!password){ dialog.error("密码不能为空"); } var url = "/index.php?m=admin&c=login&a=check"; var data = {'username':username,'password':password}; //执行异步请求 $.post $.post(url,data,function(){ }) } }
loginCotroller.class.php
<?php namespace Admin\Controller; use Think\Controller; /** * use Common\Model 这块可以不需要使用,框架默认会加载里面的内容 */ class LoginController extends Controller { public function index(){ return $this->display(); } public function check(){ print_r($_POST); } }
index.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content=""> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href=""> <title>aimeecms内容管理平台</title> <!-- Bootstrap core CSS --> <link href="Public/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <![endif]--> </head> <body> <style> .s_center { margin-left: auto; margin-right: auto; } </style> <div class="s_center container col-lg-6 "> <form enctype="multipart/form-data" method="post"> <h2>请登录</h2> <label>用户名</label> <input type="text" class="form-control" name="username" placeholder="请填写用户名" required autofocus> <br /> <label class="sr-only">密码</label> <input type="password" name="password" id="inputPassword" placeholder="密码" required> <br /> <button class="btn btn-lg btn-primary btn-block" type="submit" onclick="login.check()">登录</button> </form> </div> <!-- /container --> <srcipt src="Public/js/jquery.js"></srcipt> <script src="Public/js/dialog/layer.js"></script> <script src="Public/js/dialog.js"></script> <script src="Public/js/admin/login.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> </body> </html>
审查元素->Network->XHR中什么都没有是什么原因
写回答
1回答
-
singwa
2017-02-17
有错误提示吗?
032017-02-27
相似问题