We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

$.ajax is not a function

Solved

$.ajax is not a function

mns-burg
Excursionist
37 0 4

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"

Accepted Solution (1)

tim
Shopify Partner
4812 598 1733

This is an accepted solution.

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.

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

View solution in original post

Reply 1 (1)

tim
Shopify Partner
4812 598 1733

This is an accepted solution.

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.

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com