jQuery is not defined or $ is not defined

One of the most common JavaScript errors we see affecting users is jQuery is not defined

If you find the same error then this is the best blog. You have found the reason and solution below steps

1) Include Main Jquery Library
This is the common issue to fix this issue first step is to check is the main library file is included in your code. IF you included it then check the path of the file, are you able to access it directly? Make sure your path does not give the 404 Erro. 404 Error means the file path that you use is not correct. You can use the CDN Link also
Just copy and paste the below code in your file if the main library not included

// Include Google's CDN
<script src="http//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

2) Cross-Browser Issue
If you are using the above CDN Link or any other CDN Link then make sure you use the same HTTP protocol. If your site is hosted with SSL means your domain name started with https then you use the same CDN path.

// If your domain start with HTTP then use this
<script src="http//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

//If your domain starts with HTTPS then use this

<script src="https//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

3. Add Library on TOP of the jquery code

Make sure you include this library file at the top of the jquery code. means first you need to include this file then use any other jquery file or add your jquery scripts.

4. CDNs might be blocked.
This issue occurs many times that your code is not working sometimes and some times it’s working. Some time the CDNs might be blocked by a filter or proxy service on your customers’ connection. So, in this case, you can download the file on your server and give the path of your own server.

Below the full script is given.

<html>
<body>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
	//include other jquery files below this script
	<script>
		$(document).ready(function () {
		  //your code here
		  console.log('jquery working');
		});
	</script>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

*