0
THIS 페이지에서 일부 더미 영지를 나열하고 각각에 대해 (VEZI TELEFON 텍스트가있는) 스팬을 클릭하여 전화 번호를 나타냅니다 . 출력되지 않습니다 원하는 결과 아래에서 볼 수 있습니다json 파일의 데이터로 span 태그 채우기
{
"telefoane":[{
"id":"1",
"tel":"0743127315"
},
{
"id":"2",
"tel":"072245875"
},
{
"id":"3",
"tel":"0756129458"
},
{
"id":"4",
"tel":"0725127216"
},
{
"id":"5",
"tel":"0723127322"
}]
}
내 코드 : 나는 모든 전화 번호는 JSON에서 검색 할 (또는 PHP) 파일이 내용이 telefoane.json라고 할
$.ajax({
url: 'telefoane.json',
dataType: 'json',
success: function(data){
$.each(data, function(key, val){
console.log(key + ":" + val);
});
}
});
출력은 불행하게도입니다 : 내가 잘못 뭐하는 거지
telefoane:[object Object],[object Object],[object Object],[object Object],[object Object]
? 고맙습니다!
편집 :
이$.ajax({
url: 'telefoane.json',
dataType: 'json',
success: function(){
$.each(data.telefoane, function() {
console.log(this.id + ": " + this.tel);
});
}
});
콘솔하지 않습니다 아무것도 출력하지 마십시오 ... – user1647234
코드를 보여주십시오. 귀하의 질문에 *). @ user1647234 – eisbehr
질문 편집 – user1647234