我正在使用以下设置一个简单的 AJAX 调用:
if(validateEmail(email_val)){
$.post($('#form_url').val(), { email: email_val }, function(data) {
console.log(data);
} );
}
一切正常,但我如何访问“状态”:true?
我想要做:
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);
}