Reputation: 2520
Hello im working with code igniter and I try to send parameters from url into view to controller
My Controller
public function mainView($num=null) {
$this->load->view('header');
// $data = array('foo[' => 'Hello', 'bar' => 'world');
if (!isset($_SESSION[$this::jsondevices])) {
var_dump("Descargo");
$_SESSION[$this::jsondevices] = $this->restlib->consumirDominiosDeMoca($this->restmodel->modelUserDevices());
$_SESSION[$this::jsontags] = $this->restlib->consumirDominiosDeMoca($this->restmodel->modelTagsMoca());
}
var_dump("No descargo");
$data = $this->piemodel->mainValues($this, $_SESSION[$this::jsondevices], $_SESSION[$this::jsontags]);
$this->load->view('user/login/vistachart', $data);
$this->load->view('footer');
}
My js
window.location.href = "<?= base_url('home2/$1')?>";
And my route
$route['home2/(:num)'] = 'user/mainView/$1';
And the result
404 Page Not Found
But I try with $route['home'] = 'user/mainView';
Work's
What Im doing wrong?
Upvotes: 0
Views: 1061
Reputation: 6994
Send your parameter like this in js:
window.location.href = "<?= base_url('home2/1')?>";
it redirects to user/mainView/1
where 1
is parameter.
Also don't forget to load url
helper in application/config/autoload.php
.
Upvotes: 1