그 기능 문제가 콘솔 catch되지 않은 형식 오류에 대한 표시 널 (null) : 널 (null) 및 understant 캔트의 특성 '길이'를 읽을 수 없습니다 이유catch되지 않은 형식 오류 : 재산 '길이'를 읽을 수 없습니다 JSON-JQUERY는
function shownameplaylist(){
$.getJSON("js/json/nameplaylist.json", function(data) {
var items = [];
$.each(data, function(key, value) {
$('#nameplaylist').append('<option>'+value.title+'</option>')
});
$('.nameplaylist option:first-child').attr("selected", "selected");
nameplaylist=$(".nameplaylist option:selected").text();
console.log(nameplaylist.length);
if(nameplaylist.length==0){
$('#nameplaylist').css('display','none');
$('#delplaylist').css('display','none');
}
}).done(function(){ // If the AJAX call encountered an error
showplaylist();
})
.fail(function(){ // If the AJAX call encountered an error
console.log('no load nameplaylist');
$('#nameplaylist').css('display','none');
$('#delnamelist').css('display','none');
$('#delplaylist').css('display','none');
});
}
이'nameplaylist' 변수가 실제로 아무것도 포함되어 있습니까 :
코드를 보면, 당신의 수정은 단순히 라인 (7)을 변경하고 8 것입니다 상상? –
'nameplaylist'는 ID 또는 클래스입니다. 두 가지 방법으로 사용했습니다. –
null 그는 null을 정의합니다. 여기에 문제가 있습니다. $ .each (data, function (key, value) { $ ('# nameplaylist'). append ('') }); – Cazs