POST http:// localhost/MyApp/MyCon/customerCheck 500(内部服务器错误)

POST http:// localhost/MyApp/MyCon/customerCheck 500(内部服务器错误)

问题描述:

config:$ config ['base_url'] ='http://localhost/myApp/';POST http:// localhost/MyApp/MyCon/customerCheck 500(内部服务器错误)

我要检查,如果电子邮件已经在数据库中存在与否。我以注册形式调用了输入字段的函数(emailCheck())onblur,它在控制器中作为视图给出。

AJAX代码:

function emailCheck(){ 
    var email = jQuery("#email").val();; 
    jQuery.ajax({ 
     type: 'POST', 
     url: "<?php echo site_url(); ?>myCon/customerCheck", 
     data: {"email":email}, 
     success:function(response){ 
      if(response.status=="success"){ 
       $('#test').html(response.message); 
      } else { 
       console.log(response.message) 
      } 
     } 
    }); 
} 

控制器代码:

<?php 
    defined('BASEPATH') OR exit('No direct script access allowed'); 
    /** 
    * 
    */ 
    class MyCon extends CI_Controller 
    { 
     public function customerCheck(){ 
      if ($this->input->is_ajax_request()) { 
       $this->load->model('CustomerModel'); 
       $mail = $this->input->post('email'); 
       $res = $this->customerModel->customerMailCheck($mail); 
       if(!empty($res)) { 
        $data['status'] = 'success'; 
        $data['message'] = 'Email Adress is found'; 
       } else { 
        $data['status'] = 'error'; 
        $data['message'] = 'Data not found'; 

       } 
       echo json_encode($data); 
       exit; 
      } else{ 
       redirect('somelink'); 
      } 
     } 
    } 
?> 

型号代码:

<?php 
    class CustomerModel extends CI_Model{ 
     function __construct() 
     { 
      parent:: __construct(); 
     } 
     function customerMailCheck($mail){ 
      $result = $this->db->get_where('privilege_customer', array('email' => $mail)); 
      return $result->result(); 
     } 
    } 
?> 
+4

检查你的日志。 –

+0

@ Fred-ii-得到这两个错误 未定义的属性:MyApp :: $ customerModel C:\ wamp \ www \ myApp \ application \ controllers \ MyApp.php& 调用成员函数customerMailCheck()null –

+0

通话失败明显。可能会出现CI命名约定......'类Customer_model'和' - > model('customer_model')'也许?然后使用'$ this-> customer_model-> foo()' – ficuscr

$res = $this->customerModel->customerMailCheck($mail); 

如果型号名称是区分大小写的话,应该是

$res = $this->CustomerModel->customerMailCheck($mail);