2017-07-01 7 views
1

こんにちはみんな:私のコードでgetJSONメソッドのエラーを修正する方法は?私は次のエラーを取得しています

Failed to load resource: the server responded with a status of 403 (Forbidden) 
jquery-3.1.1.slim.min.js:2 jQuery.Deferred exception: $.getJSON is not a function TypeError: $.getJSON is not a function 
    at HTMLDocument.<anonymous> (http://localhost/whatever/js/super.js:15:4) 
    at j (https://code.jquery.com/jquery-3.1.1.slim.min.js:2:30164) 
    at k (https://code.jquery.com/jquery-3.1.1.slim.min.js:2:30478) undefined 
r.Deferred.exceptionHook @ jquery-3.1.1.slim.min.js:2 
jquery-3.1.1.slim.min.js:2 Uncaught TypeError: $.getJSON is not a function 
    at HTMLDocument.<anonymous> (super.js:15) 
    at j (jquery-3.1.1.slim.min.js:2) 
    at k (jquery-3.1.1.slim.min.js:2) 

私のJSONコードはこれです:

\t $.getJSON('../whatever/data/comments.json', \t function (data) { 
 
\t \t var commentStr = '<ul class="list-unstyled">'; 
 
\t \t $.each(data , function (i ,item) { 
 
\t \t \t // body... 
 
\t \t \t commentStr += '<li class="media my-4">'; 
 
\t \t \t commentStr += '<img class="d-flex mr-3" src="..." alt="Generic placeholder image">'; 
 
\t \t \t commentStr += '<div class="media-body">'; 
 
\t \t \t commentStr += '<h5 class="mt-0 mb-1">'+ item.name +'</h5>'; 
 
\t \t \t commentStr += '' + item.comment + '</div></li>'; 
 
\t \t }); 
 
\t \t $("#comment").html("commentStr"); 
 
\t });

任意の助けが理解されるであろう!

+0

問題はクライアント側ではなく、サーバーが「禁止」で返信しています。それぞれのファイル/フォルダの設定を確認してください。 – Sirko

答えて

3

JQueryのフルバージョンを含みます。あなたがslimバージョンを使用しているようです。おそらく、$.getJSON()関数やその他のajaxコール関数は含まれていない可能性があります。したがって、エラー - Uncaught TypeError: $.getJSON is not a function

だから、使用 - あなたのheadタグで

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

を。

関連する問題