Reputation: 189
I am developing a website. Everything is going fine. But now I need to add jQuery functionality to it, but it does not work using the relative path.
Here is my web directory structure:
ROOT
application
model
view <== index.php resides here.
controller
includes
public
css
js <== myfile.js AND jquery.js resides here.
images
This is how i am giving the relative path in the script tags.
src="../public/js/jquery.js" <== the jquery file relative source
src="../public/js/myfile.js" <== the my custom file relative source
Upvotes: 1
Views: 3236
Reputation: 5257
Don't use relative path. It's trouble.
The easier way to make your script always point to the right place, no matter which page you visit, is to start with a slash at the first level directory.
If 'public' is at the public html root.
Then use src="/public/js/jquery.js"
If the first folder is 'js'.
Then use src="/js/jquery.js"
Upvotes: 1