我有两个使用 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 对象中的国家列表中查找国家代码并放置其完整国家。所以我可以显示
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
});