数据表错误,打印无法读取控制台中未定义的属性“行”

时间:2019-06-19 13:24:21

标签: jquery datatables

我有三个ajax调用。首先使用第一个ajax填充表,然后使用第二个和第三个ajax再次进入表,但是该概率出现在行未定义的地方。在我的代码中,我试图找到与该ID匹配的那一行并输入。但我无法这样做。

alert("C");
$(document).ready(function($) {
  table = $('#weeklysummary').DataTable(); {
    $.ajax({
      url: "xyz.php",
      success: function(querryResult) {
        alert("B");
        rowData = JSON.parse(querryResult);
        console.log(rowData);
        for (var i = 0; i < rowData.length; i++) {
          if (rowData[i].rental_status == "active") {
            table.row.add([
              rowData[i].id,
              rowData[i].name,
              rowData[i].day,
              " ",
              " ",
              rowData[i].attendence,
              " ",
            ]).draw(false);
          }

        }

      }
    });
    $.ajax({
      url: "abc.php",
      success: function(online_time_received) {
        alert("A");
        var time2 = JSON.parse(online_time_received);
        temp4 = Object.keys(time2);
        temp3 = Object.values(time2);
        console.log(temp4);
        console.log(temp3);
        for (i = 0; i <= temp4.length; i++) {
          var column = $('#weeklysummary').dataTable().fnFindCellRowIndexes(temp4[i], 0)
          table
            .cell(column, 4)
            .data(temp3[i])
            .draw(false);
        }
      }
    });
    $.ajax({
      url: "efg.php",
      success: function(value_received) {
        //alert("D");
        var last_time = JSON.parse(value_received);
        temp = Object.keys(last_synctime_for_rentals);
        temp2 = Object.values(last_synctime_for_rentals);
        console.log(temp);
        for (var i = 0; i < temp.length; i++) {
          var column = $('#weeklysummary').dataTable().fnFindCellRowIndexes(temp[i], 0)
          table
            .cell(column, 3)
            .data(temp2[i])
            .draw(false);
        }
      }
    });
  }
});

0 个答案:

没有答案