jquery – TypeError: $.ajax(…) is not a function?

jquery – TypeError: $.ajax(…) is not a function?

Neither of the answers here helped me. The problem was: I was using the slim build of jQuery, which had some things removed, ajax being one of them.

The solution: Just download the regular (compressed or not) version of jQuery here and include it in your project.

Double-check if youre using full-version of jquery and not some slim version.

I was using the jquery cdn-script link that comes with jquery. The problem is this one by default is slim.jquery.js which doesnt have the ajax function in it. So, if youre using (copy-pasted from Bootstrap website) slim version jquery script link, use the full version instead.

That is to say use
<script src=https://code.jquery.com/jquery-3.1.1.min.js>
instead of
<script src=https://code.jquery.com/jquery-3.1.1.slim.min.js

jquery – TypeError: $.ajax(…) is not a function?

Not sure, but it looks like you have a syntax error in your code. Try:

  type: POST,
  url: url,
  data: postedData,
  dataType: json,
  success: callback

You had extra brackets next to $.ajax which were not needed. If you still get the error, then the jQuery script file is not loaded.

Leave a Reply

Your email address will not be published.