Wednesday, July 14, 2021

TypeError: $.ajax is not a function

 You may encounter an error similar to the following:

Uncaught TypeError: $.ajax is not a function
    at HTMLDocument.<anonymous> ((index):86)
    at j (jquery-3.4.1.slim.min.js:2)
    at k (jquery-3.4.1.slim.min.js:2)

The issue here is that the Slim version of JQuery doesn’t support Ajax.

Slim Version

<script
  src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
  integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8="
  crossorigin="anonymous"></script>

Regular Version

Instead, use the regular version of JQuery and the error will go away:

<script
  src="https://code.jquery.com/jquery-3.4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous"></script>

No comments:

Post a Comment