This tutorial, we will discuss how to fix an error that comes in SharePoint Online: $ in undefined jquery / Uncaught ReferenceError: $ is not defined or Uncaught TypeError: Cannot read property ‘SPGetCurrentUser’ of undefined, the error comes in the javascript object model.
Uncaught ReferenceError: $ is not defined
Recently I was working with the client object model in SharePoint online. In that demo, I was using the JavaScript object model (jsom) and also I was using jQuery also. I put the code inside a script editor web part inside the SharePoint Online web part page. But I got the error like below:
Uncaught ReferenceError: $ is not defined. It looks like below:

The problem was also coming because the jQuery was not loading properly on the page. To work with jQuery we need to refer jQuery.min.js file. Once I gave the references like below, the error did not come.
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
Uncaught TypeError: Cannot read property ‘SPGetCurrentUser’ of undefined
While working with SharePoint online client object model, I got the below error which says: Uncaught TypeError: Cannot read property ‘SPGetCurrentUser’ of undefined. It looks like below:
I was using SPServices to retrieve current user details like below:
var thisUser = $().SPServices.SPGetCurrentUser();

To work with SPServices, we need to refer both jquery.min.js and jquery.SPServices-2014.02.min.js files like below:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js"></script>
Once you will refer the above .js files then the error will not come.
You may like following jQuery tutorials:
- Uncaught ReferenceError: function is not defined
- Cascading dropdown in SharePoint 2013/2016/Online using jQuery
- How to retrieve Query String Value using JQuery in SharePoint Online?
- Bind current date to date picker control using jQuery in SharePoint Online
- Display SharePoint list data in html table using jquery and javascript object model
- Hide page title in SharePoint Online/2013/2016/2019 using jQuery or CSS
- Bind SharePoint Online List Data into HTML table or jQuery Datatable using jQuery and Rest API
- bootstrap’s JavaScript requires jQuery error in SharePoint Online
- How to make synchronous Rest API call in SharePoint Online
This tutorial, we learned how to fix error, Uncaught ReferenceError $ is not defined and Uncaught TypeError Cannot read property ‘SPGetCurrentUser’ of undefined
Hello Everyone!! I am Bhawana a SharePoint MVP and having about 10+ years of SharePoint experience as well as in .Net technologies. I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools. Now exploring more in SharePoint 2016 🙂 Hope here I can contribute and share my knowledge to the fullest. As I believe “There is no wealth like knowledge and no poverty like ignorance”