以下を使用して、単純な AJAX 呼び出しを設定しています。
if(validateEmail(email_val)){
$.post($('#form_url').val(), { email: email_val }, function(data) {
console.log(data);
} );
}
それはすべて機能しますが、「ステータス」にアクセスするにはどうすればよいですか?
私はやってみたいです:
if(status is true){ call this function }
if (array_key_exists('email', $_POST)) {
$this->form_validation->set_rules(array(
array(
'field' => 'email',
'label' => 'Email',
'rules' => 'trim|required|xss_clean|valid_email'
),
)
);
if($this->form_validation->run() === FALSE) {
$data = array('status' => FALSE, 'error' => $this->form_validation->error_array());
}
else {
if($this->pages->addEntry()==true){
$data = array('status' => TRUE, 'error' => FALSE);
} else {
$data = array('status' => FALSE, 'error' => 'You already participate in the competition');
}
}
echo json_encode($data);
} else {
$dupe = false;
if(is_numeric($id)) {
$this->page = $this->pages->getSingleById($id, array('timestamps' => 2, 'files' => 5, 'longtexts' => 2, 'varchars' => 3));
$this->page["timeLeft"] = $this->pages->countLeftTime($this->page["timestamps_1"]);
} else {
$this->page = $this->pages->getCurrentCompetition();
}
$this->view_vars = array(
'page' => $this->page,
'dupe' => $dupe,
'signed_request' => $_REQUEST['signed_request'],
);
return $this->load->view('html/pages/index', $this->view_vars);
}