写一下前端用ajax 或者angular的$http,与后端交互的代码就是后端需要写什么代码怎么传API给前段,前端怎么接受,用post或者get传给后端什么?css样式不用考虑我自己脑补,就是交互之间的代码不懂
1 回答
慕的地6264312
TA贡献1817条经验 获得超6个赞
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;
}
}添加回答
举报
0/150
提交
取消
