-2
$.when(
$.getJSON('pathto/test/collection.json'),
$.getJSON('pathto/test/ad.json')
).then(function(collection, advertised){
var items = collection.collections.concat(advertised.advertised);
alert(items);
});
의 특성 'CONCAT'을 읽을 수 없습니다 그것은 경고 메시지 주었다 [object Object],success,[object Object],[object Object],success,[object Object]
는 오류가 계속 : catch되지 않은 형식 오류를 : 정의되지 않은
두 JSON 파일 (URL을)
{
"advertised": [
{ "title": "Rabbit",
"subtitle": "Nibble",
"advertised": true
},
{ "title": "Dog",
"subtitle": "Woof",
"advertised": true
},
{ "title": "Cat",
"subtitle": "Purr",
"advertised": true
}
]
}
{
"collections": [
{ "title": "Horse",
"subtitle": "Na~~",
"advertised": false
},
{ "title": "Turkey",
"subtitle": "Gobble",
"advertised": false
},
{ "title": "Goat",
"subtitle": "Baaaa",
"advertised": false
},
{ "title": "Snake",
"subtitle": "hissssss",
"advertised": false
}
]
}
가 결합하는 노력 해왔다를 이 2 json 파일에서 이러한 데이터를 그래서 나는 제목, 이름 등을 표시하는 var 항목을 사용할 수 있습니다. 같은 오류가 점점 계속.
감사합니다. 당신은 JSON 객체 내에서 볼 수 만있게
$.when(
$.getJSON('collection.json'),
$.getJSON('ad.json')
).then(function(collection, advertised){
var items = collection[0].collections.concat(advertised[0].advertised);
alert(JSON.stringify(items));
});
내가 경고에 JSON.stringify을 사용했습니다 :
사용 json.parse() –
두 개의 jsons를 결합하려고합니까? 또는 다른 것..? 수술 후 예상되는 구조의 구조는 무엇입니까? –
당신은 오류와 경고가 동시에 발생하고 있다고 말하고 있습니다. 'concat'가 에러를 던지고 있다면, 경고를받지 못할 것입니다. 경고가 작동 중이므로 오류가 없습니다. 문제를 보여주는 예제를 제공해주십시오. –