我正在使用 Jquery Ui 自动完成。
我遇到的问题是从我的 api 返回的数据。
"{"d":{"results":[],"facets":{"facet_counts":{"Town":{"":0,"londonderry":136914,"london bridge":1,"london":8983316,"london colney":1}}},"__solr_time":3473457,"__ser_time":1564,"__t_time":1421,"__count":9120232,"__max_score":1.0}}"
我已经通过在线解析器运行了它,它是有效的,但我不知道如何访问旁边有相应编号的城镇列表。
如有任何帮助,我们将不胜感激
最佳答案
我能够使用以下方式访问城镇“名称”和号码:
var test = {
"d": {
"results": [],
"facets": {
"facet_counts": {
"Town": {
"": 0,
"londonderry": 136914,
"london bridge": 1,
"london": 8983316,
"london colney": 1
}
}
},
"__solr_time": 3473457,
"__ser_time": 1564,
"__t_time": 1421,
"__count": 9120232,
"__max_score": 1
}
}
for(var prop in test.d.facets.facet_counts.Town){
console.log(prop);
console.log(test.d.facets.facet_counts.Town[prop]);
}
关于javascript - 从 Ajax 调用 Jquery 访问数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15035090/