if ($form->validate()) $result = array('status' => 1); else $result = array('status' => 0, 'errors' => $form->getAllErrors()); echo json_encode($result);