[英]Google Visualization API load 2 scripts on the same HTML
[英]Anything change with Google Apps Scripts or Visualization API in the last 24 hours?
在2016年4月7日(星期四)中午左右,我失去了其中一個Google Script WebApp的所有新實例的功能。
我廣泛使用JavaScript的google.visualization.Query(
...,用於從大型Google表格文件中快速搜索。
在撰寫本文時,一個先前加載的Web應用程序實例仍在成功運行,但是所有新加載的實例均失敗。 我已經提取了該工作實例的源代碼,它與非工作實例相同。 我創建了一個新項目,並且新項目實例(具有相同的代碼)在所有瀏覽器中也都失敗了。
我很困惑
這是我懷疑的一小段代碼。 這是一個遞歸函數,它在一個電子表格上查詢兩個工作表(構建和構建),然后從另一個電子表格中查詢另一個工作表(存檔),並將結果設置為3個數據表。
function queryThings(response)
{
// If this is the first call to query
if(response == null)
{
sessionStorage.setItem("qIndex_H", "0");
// Building Query
var query = new google.visualization.Query(s_thingsBuilding + '&tq=select+*+where+LOWER(' + key1 + ')+contains+%27' + sessionStorage.getItem("stringInput") + '%27');
query.send(querythings);
return;
}
// if This is the second call
if(sessionStorage.getItem("qIndex_H") == "0")
{
sessionStorage.setItem("qIndex_H", "1");
//Store build sheet dataTable in sessionStorage
sessionStorage.setItem("thingTable1", response.getDataTable().toJSON());
// Show or hide the div
if(response.getDataTable().getNumberOfRows() > 0)
$("#thingsBuilding").show();
else
$("#thingsBuilding").hide();
var query = new google.visualization.Query(s_thingsBuilt + '&tq=select+*+where+LOWER(' + key1 + ')+contains+%27' + sessionStorage.getItem("stringInput") + '%27');
query.send(querythings);
return;
}
// if This is the third call
if(sessionStorage.getItem("qIndex_H") == "1")
{
sessionStorage.setItem("qIndex_H", "2");
//Store build sheet dataTable in sessionStorage
sessionStorage.setItem("thingTable2", response.getDataTable().toJSON());
// Show or hide the div
if(response.getDataTable().getNumberOfRows() > 0)
$("#thingsBuilt").show();
else
$("#thingsBuilt").hide();
var query = new google.visualization.Query(s_thingsArchive + '&tq=select+*+where+LOWER(' + key1 + ')+contains+%27' + sessionStorage.getItem("stringInput") + '%27');
query.send(querythings);
return;
}
sessionStorage.setItem("qIndex_H", "0");
var dt1 = new google.visualization.DataTable(sessionStorage.getItem("thingTable1"));
var dt2 = new google.visualization.DataTable(sessionStorage.getItem("thingTable2"));
// Show or hide the div
if(response.getDataTable().getNumberOfRows() > 0)
$("#thingsArchive").show();
else
$("#thingsArchive").hide();
if(dt1.getNumberOfRows() + dt2.getNumberOfRows() + response.getDataTable().getNumberOfRows() == 0)
$("#thingsDiv").hide();
setTable_DT(dt1, "thingsBuilding");
setTable_DT(dt2, "thingsBuilt");
setTable_DT(response.getDataTable(), "thingsArchive");
}
控制台輸出:
未捕獲的錯誤:缺少請求ID的查詢:0VM60 userCodeAppPanel:170
未捕獲的TypeError:無法讀取nullqueryThings的屬性'toJSON'@ VM60 userCodeAppPanel:170R.eC @ format + en,default + en,ui + en,corechart + en.I.js:288xw @ format + en,default + en,ui + en,corechart + en.I.js:283(匿名函數)@ format + en,默認+ en,ui + en,corechart + en.I.js:287
VM60 userCodeAppPanel:243
...
未捕獲的TypeError:無法讀取null的屬性“ toJSON”
...
過去,我讓Google Apps腳本代碼崩潰了幾個小時,僅是為了使功能自行恢復。 有人知道最近對API的任何更改可能會影響我的代碼嗎? 我認為它與瀏覽器無關,因為它無法在IE,Firefox和Chrome上運行。 一個可以正常運行的先前加載的實例已加載到Chrome。 誠然,我在此文件中沒有太多錯誤檢查代碼,但是消除過程讓我懷疑對Apps Script或Visualization API的更新。
最高
我錯誤地加載了“表格”和“ Corechart”可視化程序包。
誠然,它很草率,但是我仍然不確定為什么它昨天就起作用了,但今天卻不起作用。
google.load('visualization', '1', {packages: ['corechart']});
google.load("visualization", "1.1", {packages:["table"]});
被替換為
google.load("visualization", "1.1", {packages:["table", "corechart"]});
我的猜測是“ Corechart”包已被“ Table”包覆蓋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.