My javascript is returning this error: $.ajax is not a function

jQuery 3 slim version doesn't support ajax.

According to the release docs,

Along with the regular version of jQuery that includes the ajax and effects modules, we’re releasing a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code.

To use .ajax method, simply use the full version one.

Try this one (jquery-3.2.1.min.js) instead of slim (jquery-3.2.1.slim.min.js)

  <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

You are using slim version of jQuery. It Doesn't support ajax Calling. Use

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

instead of it.

Slim build

Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for all your web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’ve released a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code. The size of jQuery is very rarely a load performance concern these days, but the slim build is about 6k gzipped bytes smaller than the regular version – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.1.1.slim.js
https://code.jquery.com/jquery-3.1.1.slim.min.js

Referred from jQuery Blog