How can I make sure the path in jQuery autocomplete to CakePHP controller / action is resolved correctly?
I have a CakePHP stack at / var / www / site
from one view under controller A I am making a jQuery ajax call:
$("#searchstring").autocomplete("/items/getitemsforautocomplete", { ... more code
when the call is started I can see from the firebug that cakephp wants to call:
http://localhost/items/getitemsforautocomplete?q=me
Note that there is no "site", resulting in a 404.
When I upload this to my site, it works as it should. How do I set this up correctly?
0
a source to share
3 answers
this is most likely due to the call level from jquery. is this http: // localhost / items / ... correct url?
The unused html tag, which is really good, sets 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
0
a source to share