404 not found error for JavaScript files when accessing web page on localhost

39

Looks like you are simply specifying the wrong path. You have not given any information about what you are actually doing so this is just speculation. You mention cgi/phpso I assume you are serving a page that generates the html by running a php script in the cgi/php directory under your page's root.

If that is the case, if the root of your page is foo, then the page you are viewing is in foo/cgi/php/ and your javascript file is probably in foo itself. Try specifying the correct path:

<script type="text/javascript" src="../../jquery.js"></script>

Or even the full URL:

<script type="text/javascript" src="http://www.foo.com/jquery.js"></script>
Share:
39

Related videos on Youtube

Sammy
Author by

Sammy

Updated on September 18, 2022

Comments

  • Sammy
    Sammy over 1 year

    I executed a program java -Xms256m -Xmx1G Sample.java -Xms2G -Xmx6G. I tested the program, it picked the first one i.e -Xms256m -Xmx1G. I was expecting it would pick the latter one. Any documentation where I can find the explanation?

  • Lawrence DeSouza
    Lawrence DeSouza over 10 years
    If I type in the url of the JS file, it gives a blank page in chrome.
  • terdon
    terdon over 10 years
    @LawrenceDeSouza please explain how your page is set up. A 40-4 error means the file was not found so you are using the wrong path. I can't tell you the right one unless you explain where your index.php or index.html file is, where your js is and where your php is. If you get a blank page then you might actually have a blank file. Is the jquery.js file really where you think it is? Is it empty?
  • Lawrence DeSouza
    Lawrence DeSouza over 10 years
    No, the JS file is not empty. It is located in the same folder as the index.php file : localhost/folder_name
  • Lawrence DeSouza
    Lawrence DeSouza over 10 years
    I made a simple html file, including the javascript, and a simple test function of the jquery. The html file gives a blank page. But when i make it a php file, I get the following error: Uncaught SyntaxError: Unexpected token {
  • terdon
    terdon over 10 years
    @LawrenceDeSouza well, that just means you have a syntax error, you have { where you shouldn't. You really need to explain this more clearly. Please edit your question and give a minimal reproducible example. At the moment, we have to guess where your files are and what they look like. You need to set up the simplest possible case that gives you this error and provide us with everything necessary to reproduce it.
  • Lawrence DeSouza
    Lawrence DeSouza over 10 years
    I gave you the example in the line above. The bracket is properly closed.
  • terdon
    terdon over 10 years
    @LawrenceDeSouza my comment was written before you posted yours. Please edit your question to add new info instead of placing it in comments, it is very hard to read. Also, if you are giving URLs, you will need to use http://localhost/foo/jquery.js.
  • terdon
    terdon over 10 years