질문은 this과 관련되어 있지만 연결된 예제와 같은 익명의 함수를 사용하는 대신 명명 된 함수를 사용하여 나는 필요하다.jQuery로 명명 된 함수와 익명의 json 데이터 가져 오기
function parseJSON()
{
$('#dictionary').empty();
$.each(data, function(entryIndex, entry) { /*error here*/
var html = '<div class="entry">';
html += '<h3 class="term">' + entry['term'] + '</h3>';
html += '<div class="part">' + entry['part'] + '</div>';
html += '<div class="definition">';
html += entry['definition'];
if (entry['quote']) {
html += '<div class="quote">';
$.each(entry['quote'], function(lineIndex, line) {
html += '<div class="quote-line">' + line + '</div>';
});
if (entry['author']) {
html += '<div class="quote-author">' + entry['author'] + '</div>';
}
html += '</div>';
}
html += '</div>';
html += '</div>';
$('#dictionary').append(html);
});
}
$(document).ready(function() {
$('#letter-b a').click(function() {
$.getJSON('b.json', parseJSON());
return false;
});
});
나는 점점 계속 이런 식으로 오류 "'데이터'을 정의되어 있지 않습니다." 어떤 사전에
[
{
"term": "BACKBITE",
"part": "v.t.",
"definition": "To speak of a man as you find him when he can't find you."
},
{
"term": "BEARD",
"part": "n.",
"definition": "The hair that is commonly cut off by those who justly execrate the absurd Chinese custom of shaving the head."
},
{
"term": "BEGGAR",
"part": "n.",
"definition": "One who has relied on the assistance of his friends."
},
{
"term": "BELLADONNA",
"part": "n.",
"definition": "In Italian a beautiful lady; in English a deadly poison. A striking example of the essential identity of the two tongues."
}
]
감사 :
이
는 JSON 파일 (익명의 기능을 완벽하게 작동)입니다 ... 나는 내가 알고, 사소한 뭔가를 실종 해요,하지만 난 그것을 얻을 수 없다 암시.
parseJSON 인수로 데이터를 전달 ... 함수 이름을 변경해보십시오 ... 이미 그 이름으로 빌드 된 함수가 있다고 생각합니다. – DG3
jQuery에 parseJSON 함수가 있습니다. 함수의 이름을 다른 것으로 변경하면 어떻게 될까요? – dezso