Welcome Guest, Not a member yet? Register   Sign In
Using jquery validation plugin to check username availability
#9

[eluser]sanks[/eluser]
I fixed it. Instead of returning the value in check() function of ajax controller I used to echo the value to true or false. Also I used $valid as variable to echo it. So the new code is as follows:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends CI_Controller {
    
                         function __construct()
    {
        parent::__construct();
    }
                        
                      function check()
                      {
                                       $this->load->model('useraccount');
                                       $result = $this->useraccount->check_availability();
                                      
                                       if($result)
                                       {
                                           $valid = "true";
                                       }
                                     else
                                     {
                                           $valid = "false";
                                     }
                                   echo $valid;
                      }

}
?>

I guess the jquery validate plugin seeks the value of $valid variable. I hope this post is useful to someone as I always found imperfect answers on this topic


Messages In This Thread
Using jquery validation plugin to check username availability - by El Forum - 07-07-2011, 06:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB