php - cakephp - getting the correct path in a javascript file -
i'm trying use $.post() jquery call in javascript file have in webroot/js folder.
the javascript file gets called in number of places , i'm struggling figure out correct path use is.
i'm using following @ moment
$.post("../../spanners/deletespanner", function(data) { alert(data); });
but using ../../ won't work in parts of app.
what can replace ../../ with?
this depends on place of app on server , how spanners controller's deletespanner action access. suppose following:
mywebsite.com/spanners/deletespanner ===> $.post("/spanners/deletespanner"... mywebsite.com/someapp/spanners/deletespanner ===> $.post("/someapp/spanners/deletespanner"...
to prove concept you, checkout demo: http://jsbin.com/apejeqa/1 in-which src of jsbin logo website accessed page level starting path /
<img src="/images/jsbin_static.png" alt="jsbin logo" />
Comments
Post a Comment