A Python
A Python

Reputation: 93

JQuery CDN not working, and local JS script not seen

I can't understand this for the life of me. I normally work with Python, but am trying to dabble a bit in web development with JQuery. I've used the CDN from google, and have done everything from putting the script below the footer (A site I found said that was the best spot), to moving it up into the header (every other site I've been to since says that is the best spot), and nothing works.

From the error in the inspection tools 'Loading failed for the with source “http://localhost:63342/HTML/Omnifood/resources/javascript/script.js”.' It suggests to me that it can't even find the .js file I created to hold my code, but it is there, defined. (See screenshots attached)

Any help getting this sorted out would be appreciated.

Screenshot of HTML and file structure, as well as error in inspection tool: enter image description here

enter image description here

Edit: The issue has been resolved in so far as the folder has been moved to the correct location (/resources/javascript/script.js), I even went in and added type="text/javascript" to all the script files just in case. Now when attempting to run script with following JQuery code:

$(document).ready(function() {
   $('h1').click(function() {
       $(this).css('background-color', '#ff0000')
   })
});

I get the following errors in inspection tool:

enter image description here

Upvotes: 1

Views: 1132

Answers (1)

Rali
Rali

Reputation: 56

The path is wrong http://localhost:63342/HTML/Omnifood/resources/javascript/script.js

your script.js is at

http://localhost:63342/HTML/Omnifood/vendors/javascript/script.js

Upvotes: 2

Related Questions