【问题标题】:Get URL Parameter using Jquery [duplicate]使用Jquery获取URL参数[重复]
【发布时间】:2015-05-14 13:41:50
【问题描述】:

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

192.168.0.108:85/new_caretech/nurse

 192.168.0.108:85/new_caretech/index.php/nurse

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

【问题讨论】:

标签: php jquery codeigniter jquery-ui


【解决方案1】:

这取决于您的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 中更改。但现在,我们将其设置为 index.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。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-28
    • 2014-09-16
    • 2015-01-09
    • 1970-01-01
    • 2013-04-09
    • 2014-11-11
    相关资源
    最近更新 更多