I have the CakePHP stack in /var/www/site
from one view under controller AI do a jquery ajax call:
$("#searchstring").autocomplete("/items/getitemsforautocomplete", { ... more code
when the call is triggered I can see from firebug that cakephp wants to call:
http://localhost/items/getitemsforautocomplete?q=me
Note that 'site' is missing, resulting in a 404.
When I upload this to my site it works the way it should. How should I configure this correctly??
Doesn't '/' go to the root directory of the site? If your javascript file is in /var/www/site/script, you might want to do:
$("#searchstring").autocomplete("../items/getitemsforautocomplete", { ... more code }
Try using FULL_BASE_URL in your JS, like:
$("#searchstring").autocomplete("<?= FULL_BASE_URL ?>/items/getitemsforautocomplete", {
Not the most elegant way, but it solved some of my headaches in the past.
this is most likely due to the level of the call made from jquery. is the http://localhost/items/ ... the correct URL?
a not-used html tag that is really good is setting the base href. then all links and javascript calls are made from this.
<base href="http://localhost/site/">
then just remove the leading '/' from your script
$("#searchstring").autocomplete("items/getitemsforautocomplete", { ... more code
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.