Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Williams
Courses Plus Student 8,059 PointsI keep getting this error, "Failed to load script.js:1 resource: the server responded with a status of 404 (Not Found)."
I get the aforementioned error in the console, but I can't figure out what's going on for the life of me. Anyone catch my mistake?
var html = " ";
for ( var i = 1; i <= 10; i += 1 ) {
html += "<div>" + i + "</div>";
}
document.write(html);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Circles</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body id="color">
<script src = "js/script.js"></script>
</body>
</html>
2 Answers
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsHi Michael.
<!- your code ->
<script src = "js/script.js"></script>
<!- should be ->
<script src="js/script.js"></script>
As you see in your code you added a space after 'src' and after '=' sign.
It's a syntax error -> there are no spaces to be present and it says it can't load it because it can't find it - but it's just a syntax error.
Hope this helps.
mersadajan
21,306 PointsWeirdly my has no spaces but has the same error!
port-80-4q2qxiwckv.treehouse-app.com/:9 GET http://port-80-4q2qxiwckv.treehouse-app.com/js/script.js net::ERR_ABORTED 404 (Not Found)
'''<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Circles</title> <link rel="stylesheet" href="css/styles.css"> </head> <body id="color"> <script src="/js/script.js"></script> </body> </html> '''
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsHi Mersad.
Your problem is that the script could not be found because you have a / in your path which means look at the root of your file system.
// This is your code
<script src="/js/script.js"></script>
//Should be:
<script src="js/script.js"></script>
I hope this helps.
Enjoy JS :D
Michael Williams
Courses Plus Student 8,059 PointsMichael Williams
Courses Plus Student 8,059 PointsThank you Nejc. I didn't realize that whitespace mattered in HTML.
Ali Abbas
2,097 PointsAli Abbas
2,097 PointsI'm honestly surprised by this because I have space in my 'src' and '=', but my code still ran. I thought space didn't matter in coding languages and if it does, then I'm surprised my one works. Weird :-/