-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

2

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.