我有一个 json 数据。
data ={{"id":"10","name":"test"},{"id":"10","name":"test1"},{"id":"11","name":"tsst"},{"id":"41","name":"jhkj"},{"id":"11","name":"yuyyu"},}
从 json 数据中,我正在获取location
要从数据库表中获取的 id,如下所示
data.each(function( index ) {
var id = index.id //gets 10
//again gets 10 and again doing db operations for same id value
//db operations
//get location details from db using this id
// operations after getting locations....................
});
我的问题是id
重复的,即。所以也对重复值10,10,11,41 ,11
调用db
操作。如何通过调用重复 id 值的 db 操作来避免。