简体   繁体   中英

How i find out installation path on Cakephp 3

I have a Cakephp installation on a local wamp in:

c:\wwww\appname

and I have a countdown script in a view:

<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>

If i specify /users/add in the expiryUrl everything works in live enviroment but in my local environment it doesn't work because the app is installed under appname.

What is the correct way to change the code so the Ajax call works in both encironments?

The correct way would be to use the router to generate the URL, which would create a URL with respect to the base 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});

See also

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM