使用 Jquery 获取 URL 参数


Get URL Parameter using Jquery

如何使用 JQuery 获取以下 URL 的第三个 URL 段?

192.168.0.108:85/new_caretech/nurse

 192.168.0.108:85/new_caretech/index.php/nurse

我想要来自上述任一 URL 的 uri 护士

这取决于你的base_url是什么。在以下行办理登机手续appplication/config/config.php

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

默认情况下,Codeigniter 设置为您的base_url为空,但您应该将其设置为当前服务器,在您的情况下,它似乎应该192.168.0.108:85/new_caretech/并且您的index_page默认为 index.php.. 这可以在 htaccess 中更改。但现在,我们将说它的设置为索引.php。因此,要获取 URI 分隔,您需要以下内容:

如果您的 URI 是:

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

并且您想获得单词another然后使用:

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

如您所见,它将查看从左到右编号的base_url/index_page段。

然后,您可以将其设置为变量,并将其传递给JS视图或直接传递给HTML。