Error while using HTML in appscript. Error: Net state changed from IDLE to BUSY
Error while using HTML in appscript. Error: Net state changed from IDLE to BUSY
我写了一个 HTML 文件,当我尝试将数据传递到 .gs 文件以便 print or console.log
时,它不会在输出中给出日志控制台,而是在控制台中反映这些语句:
Net state changed from IDLE to BUSY
Net state changed from BUSY to IDLE
附上下面的代码 UI、HTML 文件和 .gs 文件以供参考。
HTML 输出:
HTML 文件:
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div class="container">
<div class="row">
<div class="input-field col s6">
<i class="material-icons prefix">insert_link</i>
<input id="zz" type="text" class="validate">
<label for="zz">Insert Text</label>
</div>
<div class="input-field col s12">
<button class="btn waves-effect waves-light" id="btn">Submit
<i class="material-icons right">send</i>
</button>
</div>
</div>
</div>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="testBox.gs"></script>
<script>
var gSheetUrl = document.getElementById("zz");
document.getElementById("btn").addEventListener("click",abc);
function abc(){
console.log("inside abc");
var data = {
zzz: zz.value
}
google.script.run.getData(data);
}
</script>
</body>
</html>
.gs 文件:
function openIndexDialog() {
var template = HtmlService.createTemplateFromFile("indexDialog");
var html = template.evaluate().setHeight(450).setWidth(600);
SlidesApp.getUi().showModalDialog(html,"Demo App");
}
function getData(data){
console.log(data)
console.log("data logged")
}
控制台输出:
Main Problem: Not able to print data when passed through getData(data)
这些不是错误消息,它们是有关服务器-客户端通信的信息日志。
每次您的客户端代码使用 google.script.run 调用 server-side 函数时,都会有一个 Net state changed from IDLE to BUSY
日志,当 server-side 函数结束时,将有一个 Net state changed from BUSY to IDLE
.
关于
Main Problem: Not able to print data when passed through getData(data)
如果你想在客户端打印数据,你在client-side上使用了console.log,而不是在server-side上。服务器端打印的日志可以在执行页面找到。
相关
- Unwanted Output In Console
我写了一个 HTML 文件,当我尝试将数据传递到 .gs 文件以便 print or console.log
时,它不会在输出中给出日志控制台,而是在控制台中反映这些语句:
Net state changed from IDLE to BUSY
Net state changed from BUSY to IDLE
附上下面的代码 UI、HTML 文件和 .gs 文件以供参考。
HTML 输出:
HTML 文件:
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div class="container">
<div class="row">
<div class="input-field col s6">
<i class="material-icons prefix">insert_link</i>
<input id="zz" type="text" class="validate">
<label for="zz">Insert Text</label>
</div>
<div class="input-field col s12">
<button class="btn waves-effect waves-light" id="btn">Submit
<i class="material-icons right">send</i>
</button>
</div>
</div>
</div>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="testBox.gs"></script>
<script>
var gSheetUrl = document.getElementById("zz");
document.getElementById("btn").addEventListener("click",abc);
function abc(){
console.log("inside abc");
var data = {
zzz: zz.value
}
google.script.run.getData(data);
}
</script>
</body>
</html>
.gs 文件:
function openIndexDialog() {
var template = HtmlService.createTemplateFromFile("indexDialog");
var html = template.evaluate().setHeight(450).setWidth(600);
SlidesApp.getUi().showModalDialog(html,"Demo App");
}
function getData(data){
console.log(data)
console.log("data logged")
}
控制台输出:
Main Problem: Not able to print data when passed through getData(data)
这些不是错误消息,它们是有关服务器-客户端通信的信息日志。
每次您的客户端代码使用 google.script.run 调用 server-side 函数时,都会有一个 Net state changed from IDLE to BUSY
日志,当 server-side 函数结束时,将有一个 Net state changed from BUSY to IDLE
.
关于
Main Problem: Not able to print data when passed through getData(data)
如果你想在客户端打印数据,你在client-side上使用了console.log,而不是在server-side上。服务器端打印的日志可以在执行页面找到。
相关
- Unwanted Output In Console