Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to simply use $(document).ready(function() {} But I am facing following error Uncaught ReferenceError: $ is not defined in Javascript. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
How Uncaught ReferenceError: $ is not defined Error Occurs ?
I am trying to simply use $(document).ready(function() {} But I am facing following error.
Uncaught ReferenceError: $ is not defined
How To Solve Uncaught ReferenceError: $ is not defined Error ?
How To Solve Uncaught ReferenceError: $ is not defined Error ?
To Solve Uncaught ReferenceError: $ is not defined Error You just need to Add jquery scripts in Header. Second solution is In My case I was just copy pasted their suggested snippet for jQuery on their CDN page. So You just need to use HTTP or HTTPS before Use CDN just like this: <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js”></script> And My error solved successfully.
Uncaught ReferenceError: $ is not defined
To Solve Uncaught ReferenceError: $ is not defined Error You just need to Add jquery scripts in Header. Second solution is In My case I was just copy pasted their suggested snippet for jQuery on their CDN page. So You just need to use HTTP or HTTPS before Use CDN just like this: <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js”></script> And My error solved successfully.
Solution 1: Add jquery scripts in Header
You just need to Add jquery scripts in Header.
<script language="JavaScript" type="text/javascript" src="/js/jquery-1.2.6.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/jquery-ui-personalized-1.5.2.packed.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/sprinkle.js"></script>
Solution 2: Use http or https in CDN
In My case I was just copy pasted their suggested snippet for jQuery on their CDN page Just like this.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
So You just need to use HTTP or HTTPS before Use CDN just like this.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
And My error solved successfully.
Solution 3: Use your JS script After jQuery script link.
If you are using Custom Script Before loading jQuery script link Then You will face this error so You just need to put your .js
file before the jQuery script link. Here is Example.
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="mycustomscript.js"></script>
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read