Ive created a backbone application that sends form data to the codeigniter backend for verification using a MySQL database. Below is the authenticate event of the backbone view that will be called on submission of the form,
authenticate: function(event) {
      var usernameValue = $('#username').val();
      var passwordValue = $('#password').val();
      var c = new MyQuiz();
      var userDetails = {
        'username': usernameValue,
        'password': passwordValue
      }
      c.save(userDetails, {
        type: 'POST',
        url: '/CW2/ASSWDCW2/cw2app/index.php/User/loginUser',
        success: function(model, response) {
          alert('Form data submitted successfully :' + response);
        },
        error: function(model, response) {
          alert('Error saving model');
        }
      }).done(function(model, response) {
        console.log('Done saving model');
      });
    }
I'm getting this data to the User controller and after successfully authenticating the data, I want to redirect to Home controller where the home_view will be called in the index function.
    public function loginUser()
{
    if ($this->input->server('REQUEST_METHOD') == 'POST') {
        $data = $this->decode_data($this->input->raw_input_stream);
        $username = $data['username'];
        $password = $data['password'];
        $this->load->model('UserModel');
        if ($this->UserModel->authenticate($username, $password)) {
            $this->session->is_logged_in = true;
            $this->session->username = $username;
            //sucessfully athenticated
            redirect('/Home/');
        } else {
            $this->session->login_error = True;
            redirect('/User/');
        }
    }
}
Problem : It wont redirect to Home controller once authenticated successfully.Please help!