-1

How can I get the third URL segment for the following URL using JQuery ?

192.168.0.108:85/new_caretech/nurse

and

 192.168.0.108:85/new_caretech/index.php/nurse

I want the uri nurse from either of the above mentioned URL's

H Dindi
  • 1,484
  • 6
  • 39
  • 68

1 Answers1

0

It depends on what your base_url is. Check in appplication/config/config.php on these lines:

$config['base_url'] = '';
$config['index_page'] = '';

By default, Codeigniter is set so that your base_url is blank but you should set this to your current server, in your case it seems like it should be 192.168.0.108:85/new_caretech/ and your index_page is defaulted to index.php.. this can be changed in htaccess. But for now, we will say its set to index.php. Therefore to obtain your URI segements you need this:

if your URI is:

192.168.0.108:85/new_caretech/index.php/some/another

and you want to get the word another then you use :

$this->uri->segment(2);

As you can see, it will look at the segments past your base_url/index_page numbered from left to right.

You can then set this to a variable and pass it to your view for JS or directly to HTML.

CodeGodie
  • 12,116
  • 6
  • 37
  • 66