Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter redirect does not update url using jQuery mobile

I have a login controller, which is suppose to redirect to my index page when the user is valid. The redirect works, but at the index page the url is still that of the validation method ex: login/validate_login/. If i click on a link on the index page, and then try and go back in the brower history, the browser points me to the validate method and not the index page.

How do i fix this?

I have tried using redirect with both refresh and location, but both with no luck.

I suspect this is a problem with the ajax call of jQuery mobile, but i'm not sure.

Any help appreciated. Kind regards

NOTE: I would post an image of the url at the index page, but i'm not allowed to because i'm a new user.

My validate method:

    function validate_login($controller='',$method='') {
    $this->load->library('form_validation');
    $this->load->model('workout_model');

    $this->form_validation->set_rules('ex_password','Koden','trim|required|min_length[4]|max_length[4]|callback_pw_check');


    if($this->form_validation->run() == FALSE) {
        $this->index();
    } else {
        if($query = $this->workout_model->validate()) {

            $data = array(
            'is_logged_in' => true,
            'user_id' => $query->id,
            'current_exercise' => '1'
            );

            $this->session->set_userdata($data);

            if($controller=='' || $method=='') {
                redirect("workout");
            } else {
                redirect($controller."/".$method);
            }
        } else {
            $this->index();
        }
    }
}
like image 683
Attaque Avatar asked Sep 15 '26 23:09

Attaque


1 Answers

Two things seem to be necessary for the URL to be correctly updated: use redirect(...) instead of method calls AND disable jQuery Mobile ajax call. Two ways of doing that: add and attribute to the link that initially points to your method,

<a href='.../validate_login/...' data-ajax='false'>...</a>

or, disable ajax calls globally by editing the settings (not tested).

like image 93
Manu Torres Avatar answered Sep 17 '26 14:09

Manu Torres



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!