I am trying to include a .js file into a php file. My folder structure looks like this:
root
---js (FOLDER)
------file.js
---blog (FOLDER)
------index.php
------js (FOLDER)
---------blog.js
If I am using this:
<script type="text/javascript" src="../js/blog.js"></script>
it works just fine.
What I can't seem to do is include file.js from under the root's "js" directory. I've tried everything I can think of but I just can't seem to make it work.
<script type="text/javascript" src="/js/file.js"></script>
would reference the javascript file in the top level js directory
To access the blog, is a user going to www.domain.com or www.domain.com/blog?
If /root/blog is your DOCROOT in your web server, the /root/js directly likely isn't web-accessible. The location you're referencing MUST be accessible to the client's browser.
An easy way to test this is to enter the path to the JS file directly into your browser.
it looks like blog is in a subdirectory of the folder index.php is in. Discard the ../
bit.
<script type="text/javascript" src="js/blog.js"></script>
<script type="text/javascript" src="../js/file.js"></script>