我有一个json数据。Jquery代码从数组中找到重复的信息
data ={{"id":"10","name":"test"},{"id":"10","name":"test1"},{"id":"11","name":"tsst"},{"id":"41","name":"jhkj"},{"id":"11","name":"yuyyu"},}
从JSON数据我正在读取的ID从数据库表中获取location
如下
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....................
});
我proble是id
重复即10,10,11,41 ,11
。所以呼吁db
操作重复值也。我如何通过调用数据库操作重复的id值来避免。
您忘记从'data'添加测试ID的到'dup'阵列。 – stUrb
@stUrb谢谢我得到它并修复它。 –