我有以下結構 的兩個JSON數據,我使用getJSON jquery從服務器獲得。加入或查找兩個JSON數據集
countrylist = [
{ "Country": "United States", "Code": "us" },
{ "Country": "Belgium", "Code": "be" },
{ "Country": "Argentina", "Code": "ar" },
.
.
.
]
citylist = [
{ "City": "Abernant", "ContryCode": "us", "CityId"=1 },
{ "City": "Academy Park", "ContryCode": "be", "CityId"=2},
{ "City": "Abernathy", "ContryCode": "ar","CityId"=3 },
.
.
.
]
我需要顯示城市,國家在我的div我如何查找從Citylist對象countrylist的countrCode,並把它的全部國家。 因此可以顯示
Abernant, United States
Academy Park, Belgium
Abernathy, Argentina
我有此代碼到目前爲止
$.getJSON('../GetCountrylist', function (data) {
var countryList =data;
});
$.getJSON('../GetCitylist', function (data) {
//this is where i need to Join the data
//for each data dispaydata= data.City ',' + Country
});
你知道你已經乘缺少qoutes(''')吧? – andlrc
乘?不確定 –
我只是修正了這些 – MyStream