有没有大神写一个评论 或者登录注册前后端交互的代码?

写一下前端用ajax 或者angular的$http,与后端交互的代码
就是后端需要写什么代码怎么传API给前段,前端怎么接受,用post或者get传给后端什么?
css样式不用考虑我自己脑补,就是交互之间的代码不懂

千万里不及你
浏览 620回答 1
1回答

慕的地6264312

demo,前段js$.ajax({         type:"POST",         url:url+"/Index/LoginCheck",         data:{             account:$account,             pwd:$pwd         },success:function (data) {             if(data){                 alert("登录成功");             }else{                 alert("账号或密码错误");             };         }     });后端thinkphp//验证登录     public function LoginCheck(){         $account = I('account');         $pwd = I('pwd');         $user = M('admin');         $condition['account'] = $account;         $condition['pwd'] = md5($pwd);         $result = $user->where($condition)->find();        if ($result) {            $this->ajaxReturn($result);         } else {            return false;         }     }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript