Uncaught ReferenceError: $ is not defined jQuery - Javascript

  • 03-07-2022
  • 851
  • Jquery
  • Haresh Chauhan

The common reason for this error behind is Uncaught ReferenceError: $ is not defined executing jquery code before loaded jQuery library file or not imported jQuery CDN in your file.

Basically $ is the jQuery alias so when you try to call or access it before declaring the function. it will end up with throw $ is undefined.


You must need to push the reference to the jquery script first.

If you can't follow the sequence, So the jquery code loaded first and then the jquery library, because of this jquery code is not able to read without jquery library file.

<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>

If you are using the ajax form, You just need to import the ajax library.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

Have you imported the jQuery library?

// Import It Before run your jQuery code
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">



    // Import It Before run your jQuery code
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
        $(function() {

We always thanks to you for reading our blogs.


Dharmesh Chauhan

(Swapinfoway Founder)

Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us


Haresh Chauhan


We Are Also Recommending You :