Welcome Guest, Not a member yet? Register   Sign In
[Solved] $ is not defined
#1

[eluser]babazumbula[/eluser]
I have jQuery script that works fine on page until certain method is called.
Controller:
Code:
function  index(){        
        $data['main_content'] = 'login_form_view';
        $this->load->view('includes/template',$data);          
}

View:
Code:
<?php $this->load->view('includes/header'); ?>

<?php $this->load->view($main_content); ?>

<?php $this->load->view('includes/footer'); ?>

At this point everything works fine, my jQuery script is loaded and works as it should.
Now, calling validate_credentials() from the same controller, causes that jQuery stops working. In firebug console I've got error "$ is not defined", and hence js stops working. I checked whether jquery.js is loaded before calling script, and checked if $(document).ready(function(){}) is taking place, but everything seem just fine.
Code:
function validate_credentials(){
        $this->load->library('form_validation');
        $this->load->model('membership_model');
        $this->form_validation->set_rules('username','Username',
                                          'callback_correct_credentials');
        if($this->form_validation->run() == false){
           $this->index();          
        }
        else{
           // some code...            
        }
}


function correct_credentials(){
        $this->load->model('membership_model');
        if($this->membership_model->validate()){        
            return true;
        }else{
            $this->form_validation->set_message('correct_credentials', 'Incorrect
                                                username/password. Try again') ;
            return false;
         }
}

In model:
Code:
function validate(){
        $this->db->where('username',$this->input->post('username'));
        $this->db->where('password',md5($this->input->post('password')));
        $query = $this->db->get('membership');
        if($query->num_rows() == 1){
            return true;
        }
        else{return false;}
}

Basically function validate_credentials() when executing $this->index() is loading same view again (now with showing login errors), but this time jQuery is not defined, unlike index() is being called by controller at the first place.


Messages In This Thread
[Solved] $ is not defined - by El Forum - 08-01-2010, 03:17 PM
[Solved] $ is not defined - by El Forum - 08-01-2010, 03:33 PM
[Solved] $ is not defined - by El Forum - 08-01-2010, 04:02 PM
[Solved] $ is not defined - by El Forum - 08-01-2010, 04:09 PM
[Solved] $ is not defined - by El Forum - 08-02-2010, 02:15 AM
[Solved] $ is not defined - by El Forum - 08-03-2010, 09:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB