使用cake php和java脚本过滤重复的行(filter duplicate rows with cake php and java script)
我正在尝试过滤使用带有蛋糕php框架工作的java脚本附加的表。 当我点击添加新杂志时,以下代码用于添加此表,但问题是,它添加了之前添加的双行。 所以我需要过滤添加的行来删除重复的行。
/// function to show magazines data table $('#add_researches_button').click(function () { $("input[name='bstock_researchs_id[]']:checked").each(function (i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function (data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function (index, value) { CountResearches++; $("#researches").append("<tr><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); });I'm trying to filter table which is append using java script with cake php frame work . and the following code is for adding this tables when i have click on add new magazine ,, but the problem is that , It's add double rows which has been added before . So i need to filter the added rows to delete the duplicated row.
/// function to show magazines data table $('#add_researches_button').click(function () { $("input[name='bstock_researchs_id[]']:checked").each(function (i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function (data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function (index, value) { CountResearches++; $("#researches").append("<tr><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); });最满意答案
/// function to show magazines data table $('#add_researches_button').click(function() { $("input[name='bstock_researchs_id[]']:checked").each(function(i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function(data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function(index, value) { CountResearches++; if ($("#researches tr[data-id='" + value.research_serial + "']").length == 0) $("#researches").append("<tr data-id='" + value.research_serial + "'><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); }); /// function to show magazines data table $('#add_researches_button').click(function() { $("input[name='bstock_researchs_id[]']:checked").each(function(i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function(data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function(index, value) { CountResearches++; if ($("#researches tr[data-id='" + value.research_serial + "']").length == 0) $("#researches").append("<tr data-id='" + value.research_serial + "'><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); });更多推荐
发布评论