登录的时候异步登录。使用$.ajax异步请求数据,在本地测试的时候一切都是正常的,上传到服务器以后,一直报错,检查以后发现如果只要一涉及到数据库的操作,就会报500错误,一直调试很久了。一直无法成功,请万能的网友帮帮忙吧!~~感激不尽~~
function dologin() {
var tel=$("#tel").val();
if(tel == ''){
layer.msg('请输入手机号');
return false;
}
var smscode=$("#smscode").val();
var data = {tel:tel,smscode:smscode};
$.ajax({
type: "get",
url: "{:url('weixin/user/dologin')}",
data: data,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (res) {
if(res.error_code ==1){
layer.msg(res.msg+'1');
return false;
}else {
layer.msg(res.msg+'0');
// location.href = "{:url('weixin/user/orderpage')}";
}
},
error: function (res) {
layer.msg(res.msg);
return false;
}
});
//调试 简单的查询
public function doLogin(){
//return info(1,'test','','json'); // 放到这个位置就可以正常回调 处理
$userinfo = Db::name('user')->select();// 这个使用model db 都不行
return info(1,'test','','json');
}
//这是函数
function info($error_code = 0,$msg = '',$info='',$type = ''){
$res = [
'error_code'=>$error_code,
'msg' =>$msg,
'info'=>$info
];
if( isset($type) && $type=='json'){
$res = json($res);
}
return $res;
}
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
最佳答案
