$.ajax is not a function

Was trying to change the “paginate” to a “Load more” using a ajax request.
However when I call the ajax in the Console it keeps telling me*“TypeError: $.ajax is not a function”*.

I have been typing this code and following this tutorial: https://www.youtube.com/watch?v=XxDYIBGWXUs

$.ajax(
{
url:"/collections/all?page=2",
type: "GET",
dataType: "html"
}
).done(function(data)){

})

From what I can tell its because jQuery is not loaded, but as far I can understand jQuery is part of Shopify.

Typing “$” in the Console returns “ƒ $() { [native code] }
Typing “jQuery” in the Console returns “ReferenceError: jQuery is not defined

Most older themes included jQuery by default while most modern ones do not.

You can either include jQuery, but this will be a hit on your Web Vitals, or redo code without jQuery…

Or check out https://ajaxinate.elkfox.io/

Note that if you have review stars on your collection products or, say wishlist buttons – these usually run on page load only and you’d need to do an extra step to load them on newly loaded products.