In my codeigniter application i want to display the uri segments.Iam using ajax to call controller.
This is my html code
function add_store(){
var path="<?php echo base_url()?>images/loader.gif";
$("#add_store").html("<div align='center' style='margin-top:200px;'><img src="+path+" style='width:25px;' /></div>").show();
$.ajax({
type: "POST",
url: "<?php echo base_url();?>index.php/Admin/add_store/",
success: function(msg){
$("#add_store").html('');
$("#add_store").html(msg).show();
}
});
}
This is my controller code
public function add_store()
{
echo $this->uri->segment(3);
}
nothing will be displayed.How can i get uri segments?
If i use
echo $this->uri->segment(1);
Then it displays Admin but after 1 nothing will be displayed.
Looks like your controller ‘Admin’ is calling a method ‘add_store’, but there are no further segments, that’s why your 3rd one isn’t passed.
I don’t know what you want to achieve, but if you have an url like:
you would just do
without the need to call directly the uri segment.