TestProject Forum
Powered by leading experts in the test automation community

jQuery cdn not loading in localhost

I’m trying to load jquery from cdn:

https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js

when i try using jquery i get error ‘$ is not defined’
why is my jquery not loaded correctly?

Your code is not actually running on localhost, its running on local file system (file://path…)
The protocol is copied with the // link to file://ajax.googleapis.com which doesn’t exist.

You need to set up a server on your machine so that you have an actual localhost accessed with the http protocol

You should set up a server on your computer so that you’d have an actual localhost accessed with the http protocol. It would have other benefits as well since browsers act a bit differently also in other regards when the page is loaded directly from the file system.