我如何在 Cakephp 3 上找到安装路径
How i find out installation path on Cakephp 3
我在以下位置的本地 wamp 上安装了 Cakephp:
c:\wwww\appname
我在视图中有一个倒计时脚本:
<script type="text/javascript">
$(document).ready(function()
{
var austDay = new Date();
austDay = new Date(<?= $nextclaimtime * 1000;?>);
$("#countdown").countdown({until: austDay, format: 'HMS', expiryUrl: "/users/add"});
});
</script>
如果我在 expiryUrl 中指定 /users/add 在实时环境中一切正常,但在我的本地环境中它不起作用,因为该应用程序安装在 appname 下。
更改代码以使 Ajax 调用在两个环境中都有效的正确方法是什么?
正确的方法是使用路由器生成 URL,这将创建一个 URL 相对于基础 path/URL。
<?php $url = \Cake\Routing\Router::url(['controller' => 'Users', 'action' => 'add']); ?>
var expiryUrl = <?= json_encode($url) ?>;
$("#countdown").countdown({until: austDay, format: 'HMS', expiryUrl: expiryUrl});
另见
我在以下位置的本地 wamp 上安装了 Cakephp:
c:\wwww\appname
我在视图中有一个倒计时脚本:
<script type="text/javascript">
$(document).ready(function()
{
var austDay = new Date();
austDay = new Date(<?= $nextclaimtime * 1000;?>);
$("#countdown").countdown({until: austDay, format: 'HMS', expiryUrl: "/users/add"});
});
</script>
如果我在 expiryUrl 中指定 /users/add 在实时环境中一切正常,但在我的本地环境中它不起作用,因为该应用程序安装在 appname 下。
更改代码以使 Ajax 调用在两个环境中都有效的正确方法是什么?
正确的方法是使用路由器生成 URL,这将创建一个 URL 相对于基础 path/URL。
<?php $url = \Cake\Routing\Router::url(['controller' => 'Users', 'action' => 'add']); ?>
var expiryUrl = <?= json_encode($url) ?>;
$("#countdown").countdown({until: austDay, format: 'HMS', expiryUrl: expiryUrl});
另见