I am using ajax with jQuery in my cakePHP application.
and my javascript function is placed inside a javascript file.
now in my local system the files are kept
I'm updating Paul Dragoonis's answer to reflect the latest CakePHP version (2.2).
In your layout file, set the JavaScript variable with CakePHP's JSHelper: Js->set('url', $this->request->base); ?>
, where $this->request
is an instance of CakeRequest and gives information on the current request.
After the line above, write the buffer with Js->writeBuffer(); ?>
.
Then, you can access this variable in JavaScript with app.url
.