在cakephp中设置baseurl [英] Setting baseurl in cakephp

查看:80
本文介绍了在cakephp中设置baseurl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用在CakePHP中运行的应用程序,我正在使用AJAX查询。

I am working on an application which is running in CakePHP and I am using AJAX queries from within.

在所有的情况下,所有的ajax post我已经使用网址为

In all the cases for all the ajax post i have used the url as

var ht = $.ajax({
                     type: "GET",
                     url: "http://172.20.52.99/FormBuilder/index.php/forms/viewChoices/"+attribute_id,
                     async: false
                }).responseText;
var myObject = eval('(' + ht + ')');

在CakePHP中有什么办法可以给我的基本URL http ://172.20.52.99/FormBuilder/index.php/ 并在所有需要的地方调用基本URL。

Is there any way in CakePHP where I can give my base URL as http://172.20.52.99/FormBuilder/index.php/ and to call the base URL in all the places I want.

推荐答案

尝试编写以下代码

'http://'.$_SERVER['HTTP_HOST'].$this->base

$ _ SERVER ['HTTP_HOST'] ----它会给你工作主机

$_SERVER['HTTP_HOST']----it will give you working host

$ this-> base ---会给你工作的URL

and $this->base---will give you working url

这篇关于在cakephp中设置baseurl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆