我想只在列表中显示重复的项目一次,而不重复的项目想要从列表中删除,应该是正确的程序?考虑以下功能:
{
alert("Hello");
var symptomname = $('#symptomname').val();
$.getJSON('http://54.148.253.123/HHS_Service/HealthService.svc/DiseaseGetBySymptom', { SymptomName: symptomname }, function (data) {
var tasks = $.parseJSON(data.d);
alert(tasks);
$.each(tasks, function (key, value) {
$('<div data-role="collapsible" data-content-theme="a" data-collapsed="true"><h3>' + value.DiseaseName +
'</h3><ul data-role="listview" id="search1ListView" data-inset="true" data-theme="a"><li><strong>Detail:</strong><span> '
+ value.Descr +
'</span></li></ul></div>').appendTo('#foundDisease');
// refreshing collapsible created dynamically "its necessary to refresh for a jQuery look and feel"
$('div[data-role=collapsible]').collapsible({ theme: 'a', refresh: true });
$("#clear").click(function () {
$("#foundDisease").empty();
});
});
});
}
答案 0 :(得分:1)
尝试使用类似的东西:
var tasks = $.parseJSON(data.d);
tasks=$.unique(tasks);// this should remove duplicate records.
然后你的循环就开始了。