JSON
{
"AA1 1AA":{
"ExchangeCode":"XXX",
"ExchangeName":"XXXXX",
"Options":{
"10":{
"Preference":"Preference 1",
"Option 1":123,
"Option 2":1234,
"Option 3":1234,
"Option 4":1234
},
"20":{ .........
}
}
}
}
这AA1 1AA
是一个邮政编码,因此随着每个请求而变化。
jQuery
// var count = 0; is declared in document ready function so that it's global
// JSON response from server is stored in 'data'
var key, count = 0;
for (key in data.Options) {
if(data.Options.hasOwnProperty(key)) {
count++;
}
}
结果只是undefined