簡體   English   中英

如何將服務器端數據存儲到Google Apps腳本中的客戶端變量?

[英]How to store server side data to client side variable in Google Apps Script?

我的服務器端功能檢索一些電子表格數據。 我想將這些數據存儲在腳本標記內的客戶端變量中:

<script>
function myFunction(){
    var data = new Array();
    data =google.script.run.getData(); // getData() is server side function.
}

當我使用console.log獲取data ,它沒有顯示任何內容。 google.script.run以正確的方式打電話給google.script.run

提前致謝。

當服務器端功能成功運行時,您必須編寫一個回調函數來檢索數據。

function myFunction() { 
    google.script.run.withSuccessHandler(onSuccess).getData();
}

function onSuccess(data) {
    //the argument data contains the array
}

有關更多信息和示例,請參閱此文檔。

https://developers.google.com/apps-script/guides/html/reference/run

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM