Recently while working on Rest API with SharePoint Online, I got one script error which says “Uncaught TypeError: $.ajax(…).then is not a function”.
We were basically trying to retrieve the Office 365 SharePoint online server’s current date and time by using the below code.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$().ready(function () {
getSPCurrentTime(_spPageContextInfo.webAbsoluteUrl)
.done(function (value) {
alert(value.toUTCString());
})
.fail(
function (error) {
alert(JSON.stringify(error));
});
})
function getSPCurrentTime(webUrl) {
return $.ajax({
url: webUrl + "/_api/web/RegionalSettings/TimeZone",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" }
}).then(function (data) {
var offset = data.d.Information.Bias / 60.0;
return new Date(new Date().getTime() - offset * 3600 * 1000);
});
}
</script>
But when we run the above code, it gave an error as: Uncaught TypeError: $.ajax(…).then is not a function
And the error looks like below:

Uncaught TypeError: $.ajax(…).then is not a function
The error was coming because of an mismatch in the jquery file I have referred. I had referred the jQuery version like below:
https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
When I change the version and the URL like below, it started working.
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
Read some SharePoint Rest API examples:
- Create, Update and Delete SharePoint List using Rest API in SharePoint
- Retrieve SharePoint list items programmatically using jsom, rest api and csom
- Bind SharePoint list items to dropdownlist using javascript object model (jsom), Rest API and Server Object Model
- How to Display SharePoint List items using AngularJS and REST Api
- Bind SharePoint Online List Data into HTML table or jQuery Datatable using jQuery and Rest API
- Rest API filter list items created by logged in user SharePoint
- How to make synchronous Rest API call in SharePoint Online/2013/2016 using jQuery?
This tutorial, we learned how to fix error, Uncaught TypeError: $.ajax(…).then is not a function which comes in SharePoint Online.
I am Bijay a Microsoft MVP (8 times – My MVP Profile) in SharePoint and have more than 15 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com