我想检查用户电子邮件是否已存在于数据库中。为此我构建了以下代码。内部服务器错误500(codeigniter,ajax)
AJAX代码:
function emailCheck(){
console.log("hello");
var email = $("#email").val();;
jQuery.ajax({
type: 'POST',
url: '<?php echo base_url(); ?>myCon/customerCheck',
data: {email:email},
success:function(response){
$('#test').html(response);
}
});
}
myCon控制器的功能:
public function customerCheck(){
$this->load->model('CustomerModel');
$res = $this->customerModel->customerMailCheck();
echo json_encode($res);
}
customerModel
模型的功能:
function customerMailCheck(){
$mail = $this->input->post('email');
$result = $this->db->get_where('privilege_customer', array('email' => $mail);
return $result->result();
}
现在,每当我调用该函数我得到错误,指出内部服务器错误500.
有没有更好的方法来做到这一点?
检查错误日志。 – Script47
您对返回数据进行编码,但是您不会在JavaScript中解码? – Script47
500内部错误意味着你的'controller'文件有'system'错误或者其他一些'error'' –