我已经在Codeigniter框架中创建了一个由JQuery Ajax单击提交的表单。如果我们进行codeigniter表单验证,我们如何分别在输入字段旁边显示内联错误消息?
答案 0 :(得分:1)
AJAX期望一些回声,所以你必须提供它。类似的东西:
public function check_form_data()
{
//here you check your fields
if $this->form_validation->run() {
//form passed so echo something to announce AJAX
echo 'valid';
} else {
// array of errors that can be managed in AJAX response part
echo json_encode($this->form_validation->error_array());
}
}