Welcome Guest, Not a member yet? Register   Sign In
Validation error with jquery(ajax)

Hi all,

I am currently working on submitting a form and once it is submitted it will validate using CI then return it out using ajax. I have currently tried something but i am not having too much luck getting it to work. Can someone tell me what i'm doing wrong here:


$(document).ready(function() {
    url: $(this).attr('action'),
    type: 'POST',
    data: $(this).serialize(),
    dataType: 'json',
    success: function(respond) {
     if (respond.result == 'false') {
     } else {

   return false;

   $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|xss_clean|callback_dbcheck');
   $this->form_validation->set_rules('name', 'Name', 'required|min_length[3]|max_length[20]|xss_clean');
   $this->form_validation->set_rules('email', 'E-mail', 'required|min_length[3]|max_length[30]|xss_clean|valid_email|callback_verify_email');
   $this->form_validation->set_rules('password', 'Password', 'required|min_length[3]|max_length[20]|xss_clean');
   $this->form_validation->set_rules('password_conf', 'Re-type Password', 'required|min_length[3]|max_length[20]|xss_clean|matches[password]');

   if ($this->form_validation->run() == FALSE) {
    $respond['result'] = 'false';
    $respond['errors'] = validation_errors();
     echo json_encode($respond);

The odd part is when i refresh the page (before submitting) all i see is this

{"result":"false","errors":""} I don't understand why i am only getting this instead of the forms which i should be viewing

any ideas?

Theme © iAndrew 2016 - Forum software by © MyBB