Uncaught TypeError: aArray.forEach is not a function

You’ve got an array, you’re trying to loop and lo-and-behold, you come up against this error:

(index):116 Uncaught (in promise) TypeError: aArray.forEach is not a function

You’re looping an array, so how can this be?

The most common cause is actually trying to loop arround an array-like collection rather than an array itself. For example, a HTMLCollection is array-like, not an array.

Simple fix for this is to create an array from this collection using code such as:

Array.from(aArray).forEach(function(item, index){
   //your code here

$.ajax is not a function

TL;DR; Make sure you've loaded jQuery into your page.

You’re ripping your hair out. “Why won’t it work?”. You’ve already subsituted that infernal cURL request that didn’t work and now ajax isn’t working!

Don’t panic – the $.ajax(…) is not a function error is more common than you might think.

And thankfully the solution is usually pretty quick.

Have you stopped and checked that you’ve loaded jQuery onto your page?

Pro tip: remember to use the minified version on live sites.  

You can host it on your server:

<script src="jquery-3.4.1.min.js"></script>

Or you can use your favourite CDN for super performance.

Google CDN:

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

Microsoft CDN:

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>

Chill out, job done :).