Get Query String value in view in Codeigniter -
i working on codeigniter , want value query string. suppose url :http://localhost/myapp/controller/method/6.
i want 6 in view, without use of controller. have tried code did not work. below controller i.e. edit_started($c_id)
reach goal view, on goal view there button on have called refresh_div() function on loading div moveable_elements called main view i.e. goal. main url localhost/myapplication/controllername/edit_started(6)
on getting $this->uri->segment(n)
gives show_data
i.e. ajax 1 url not original 1 localhost/myapplication/controllername/edit_started(6)
.
controller:
public function edit_started($c_id) { $data['result']=$c_id; $this->load->view('goal',$data); }
view:
$(document).ready(function(){ function refresh_div() { $.ajax({ type: "post", url: "<?php echo base_url(); ?>" + "dashboard/show_data", cache: false, datatype: "json", success: function(data){ $('#demo').html(data); } });
dashboard.php
public function show_data() { $this->load->model('login_database'); $data['query']=$this->login_database->get_all_topics(); $this->load->helper('url'); $filter_view=$this->load->view('moveable_elements', $data,true); echo json_encode($filter_view); }
now moveable_elements view want query string.
try:
echo $this->uri->segment(4);
or
echo $this->uri->segment(3);
without qoutes.
Comments
Post a Comment