0

I am trying to create a website and came across an interesting problem. I have my filesystem setup like this

.

I am trying to reference some javascript files inside my <head>like so

As you can see the first two files are found and will load

according to the browser

I have multiple problems with this, the first being that paths for the first two javascript files are actually not valid, since if I ctrl+click them it brings up an error message

that the file doesn't exist. The second problem is that the third and fourth javascript files are not loading into the browser. I've tried the following paths for them.

  • /WebRoot/Assets/Js/filename.js,
  • ../WebRoot/Assets/Js/filename.js,
  • ../../WebRoot/Assets/Js/filename.js

and even a direct path but none of them worked. Does anybody have any idea why is this problem occurring?

3
  • 1
    Hi and welcome to SO. Please include code, error-messages and other output as text directly to your question. It is easier for you because you dont have to make screenshots and easier for us to help because we can copy and paste. Happy coding. Commented Sep 29, 2020 at 15:06
  • 1
    It seems that the paths for your last two script tags have a syntax problem. the path is inside the tag instead of inside the src attribute. Commented Sep 29, 2020 at 15:08
  • In addition of the comment of @StayCool, your are missing an 's' in the end of 'Assets' for the last JS src. Commented Sep 29, 2020 at 15:15

1 Answer 1

2

Your script tags are broken. You have:

<script src=""> [filename] </script>`

instead of:

<script src="[filename]"></script>`

You also appear to have inconsistent casing in your paths.

Your filesystem appears to have /Js/ (lowercase 's') but in your html you have it both ways: sometimes it's /Assets/JS and sometimes it's /Assets/Js/. This might account for your non-existent file issue.

Case-sensitivity can vary between environments so this might work sometimes, but it's still A Bad Idea™. Pick your preference (uppercase, lowercase, or a mix) but be consistent when referencing file paths.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.