用蛋糕PHP和Java脚本过滤副本行



我正在尝试使用带有蛋糕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>"
                            );

                });
/// 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>"
                    );

                });

最新更新