jQuery error: $.ajax is not a function

因為bootstrap 的關係,更新到了 jQuery 的 slim 的版本,但是 slim 版本裡沒有 $.post / $.get / $.ajax 等 object 可以使用。

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>

官方的網站:
https://blog.jquery.com/category/jquery/

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. 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.2.1.slim.js
https://code.jquery.com/jquery-3.2.1.slim.min.js

These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *