2016-12-06 12 views
5

Iは、I以下は、jQueryの以前のバージョンで作業し、基本的なfiddleですが、jQueryの3コンソールでjQueryの3スリムなAJAXの基本的な例

$(function() { 
    $.ajax({ 
     url: '/echo/json', 
     type: 'GET', 
     dataType: 'json', 
     success: function(data) { 
      console.log(data) 
     } 
    }); 
}) 

では動作しませんjQueryの3に新たなんですこのエラーが発生する:

jquery-3.1.1.slim.min.js:2 jQuery.Deferred exception: $.ajax is not a function TypeError: $.ajax is not a function

jquery-3.1.1.slim.min.js:2 Uncaught TypeError: $.ajax is not a function(…)

なぜですか?

+0

だ[だけの変更について、最大読む](https://jquery.com/upgrade-guide/3.0/#ajax) – GillesC

+0

あなたはjqueryのファイル –

+0

に接続しまし@DavidJorHpanはい、もちろんのは、 –

答えて

14

jQuery 3スリムバージョンはajaxをサポートしていません。 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.

.ajaxメソッドを使用することによる

、単にフルバージョン1を使用します。

ここで働いてfiddle

+0

これに追加するだけです:元のフィドルでjquery slimを置き換えるには、左側のメニューの「外部リソース」をクリックしてjQueryリソースを削除して追加します。 (jQueryをスリムに削除する方法はすぐに分かりませんでした) –

+0

ありがとう!とても明らかに今... –