I have three files in my templates folder wheree there is also my main.html file. However when I load the html file I get a 404 error for these 3 files. This is how I've included them in the head of the html:
<script type="text/javascript" src="date.js"></script>
<script type="text/javascript" src="daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="daterangepicker.css" />
They are all located in a templates folder in the same folder as my main.html.
Why aren't they being recognised?
Thanks
I have three files in my templates folder wheree there is also my main.html file. However when I load the html file I get a 404 error for these 3 files. This is how I've included them in the head of the html:
<script type="text/javascript" src="date.js"></script>
<script type="text/javascript" src="daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="daterangepicker.css" />
They are all located in a templates folder in the same folder as my main.html.
Why aren't they being recognised?
Thanks
Share Improve this question asked Dec 3, 2012 at 22:00 user94628user94628 3,73118 gold badges54 silver badges90 bronze badges 6- If you open a new browser tab and http:// directly to one of the files, what do you get? – Diodeus - James MacFarlane Commented Dec 3, 2012 at 22:01
-
Are you reading
main.html
from another file (you mention it is in a 'template' directory) and and outputting the result? – Nicholas Pappas Commented Dec 3, 2012 at 22:03 - [W 121203 22:01:04 web:1462] 404 GET /date.js (127.0.0.1) 0.38ms [W 121203 22:01:04 web:1462] 404 GET /daterangepicker.js (127.0.0.1) 0.31ms [W 121203 22:01:04 web:1462] 404 GET /daterangepicker.css (127.0.0.1) 0.18ms – user94628 Commented Dec 3, 2012 at 22:03
- The above is the message I get in the server log – user94628 Commented Dec 3, 2012 at 22:03
- @EvilClosetMonkey I have a base file which main.html inherits from. The script tags are located in the base html file. – user94628 Commented Dec 3, 2012 at 22:05
1 Answer
Reset to default 4Your local paths are not resolving correctly. Without seeing your directory structure I can't say for sure exactly where things are going wrong -- I'm a little confused as to where main.html
and base.html
are residing.
If main.html
is the file being loaded in the browser, your script
sources should be based off that directory. If your template directory (we'll call it 'templates') is a child of the directory where main.html
resides, you want:
<script type="text/javascript" src="templates/date.js"></script>
<script type="text/javascript" src="templates/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="templates/daterangepicker.css" />
Alternatively, you could just resolved your entire URL to the appropriate path:
<script type="text/javascript" src="http://www.myurl./templates/date.js"></script>