首页 > 解决方案 > Google App Script WebApp Array 不会从后端传递到前端

问题描述

我有一个项目,我将 Google 表格用作数据库,并将 Web 应用程序用作前端。

直到昨天,一个数据数组从后端传递到前端,但它不再起作用了。后端的 logger.log 显示我们有一个数组。但是前端永远不会收到数据。

后端代码(ssAssessmentLogic 是数据表)

function getDropDownArray(){
  var arrDevLogic = ssAssessmentLogic.getDataRange().getValues();
  var arrDevLogic =arrDevLogic.filter(function (dataRow) {return dataRow[5] == nutzerSquad})
  return arrDevLogic;

前端代码:

   function afterPageLoads(){  //Loads the Dropdowns. First gets the data from the spreadsheet and then populates the dropdowns with the array
      google.script.run.withSuccessHandler(afterDataArrayReturned).getDropDownArray();
    }

function afterDataArrayReturned(arrDevLogic){ //after the array withe the data came back from the sheet, store the data in a global html variable and pass it to the function to fill the drodown
      console.log(arrDevLogic);
      arrayOfValues = arrDevLogic.filter(function(r){return true;});
      var item = document.getElementById("sdp_ms");
      addUniqueDropdown(item, arrayOfValues, 4);
}

在加载 html 页面时,我收到一个错误,即 null 过滤器不起作用,并将控制台日志值显示为 null。如果我只运行后端函数,它会为我提供一个包含 260 个项目的数组数组。

有人可以帮我找出问题吗?

标签: javascriptgoogle-apps-scriptbackend

解决方案


看来我找到了解决方案。在数组数组中,“行数组”中的某些字段是日期,而其他字段为空白。当某些数组具有日期值而某些数组为空白时,代码的 HTML 部分似乎不喜欢它。

谢谢大家的帮助。


推荐阅读