0
config: $ config ['base_url'] = 'http://localhost/myApp/';POST http: // localhost/MyApp/MyCon/customerCheck 500 (Interner Serverfehler)
Ich möchte überprüfen, ob die E-Mail bereits in der Datenbank existiert oder nicht. Ich habe eine Funktion (emailCheck()) onblur eines Eingabefeldes im Registrierungsformular aufgerufen, das als Ansicht im Controller angegeben ist.
AJAX-Code:
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)
}
}
});
}
Controller-Code:
<?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');
}
}
}
?>
Modellcode:
<?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();
}
}
?>
überprüfen Sie Ihre Protokolle. –
@ Fred-ii- hat diese 2 Fehler Undefinierte Eigenschaft: MyApp :: $ customerModel C: \ wamp \ www \ myApp \ application \ controllers \ MyApp.php & Aufruf an eine Mitgliedsfunktion customerMailCheck() auf null –
Nun laden Anruf ist offensichtlich fehlgeschlagen. Scheint für CI-Namenskonventionen ... 'class Customer_model' und' -> model ('customer_model') 'vielleicht? Dann verwenden Sie mit '$ this-> customer_model-> foo()' – ficuscr