一尘不染

如何在jQuery中迭代JSON数据

json

如何在jquery中迭代json数据。

[{"id":"856","name":"India"},
 {"id":"1035","name":"Chennai"},
 {"id":"1048","name":"Delhi"},
 {"id":"1113","name":"Lucknow"},
 {"id":"1114","name":"Bangalore"},
 {"id":"1115","name":"Ahmedabad"},
 {"id":"1116","name":"Cochin"},
 {"id":"1117","name":"London"},
 {"id":"1118","name":"New York"},
 {"id":"1119","name":"California"}
]

阅读 276

收藏
2020-07-27

共1个答案

一尘不染

您可以这样使用$.each()

$.each(data, function(i, obj) {
  //use obj.id and obj.name here, for example:
  alert(obj.name);
});
2020-07-27