简体   繁体   English

通过客户端脚本与服务器进行GAS HTML服务通信

[英]GAS HTML service communication with server from client side script

Following the examples on https://developers.google.com/apps-script/guides/html/communication I cannot make the simplest example work when embedded in the sidebar for a spreadsheet. 遵循https://developers.google.com/apps-script/guides/html/communication上的示例,当嵌入到电子表格的边栏中时,我无法使最简单的示例生效。 If I publish the script as web app and open the URL the server side function is correctly found and executed (ie how the example is supposed to work), but when I use the same html output in the sidebar the execution always fails. 如果我将脚本发布为Web应用程序并打开URL,则可以正确找到并执行服务器端功能(即示例应如何工作),但是当我在边栏中使用相同的html输出时,执行总是失败。 Is there a way to debug what is going on on the server or is there any steps one should take when using html service embedded in sidebar to make server side calling to work? 有没有一种方法可以调试服务器上发生的情况,或者使用侧边栏中嵌入的html服务使服务器端调用正常工作时应该采取任何步骤? As explained I am using the example directly from the help page and it still does not work. 如前所述,我直接从帮助页面使用示例,但仍然无法正常工作。

[14-07-19 18:22:23:455 EEST] Starting execution
[14-07-19 18:22:23:486 EEST] Execution failed: We're sorry, a server error occurred.
                             Please wait a bit and try again. [0.0 seconds total runtime]

...when I use the doGet it works as expected ...当我使用doGet时,它按预期工作

Any ideas or help would be greatly appreciated. 任何想法或帮助将不胜感激。

Use: 采用:

Logger.log('my variable value: ' + myVariable);

to debug .gs code, then view the log. 调试.gs代码,然后查看日志。 You viewed the Execution Transcript, so I could assume that you know about Logger.log() , but that might not be the case. 您查看了执行记录,因此我可以假定您了解Logger.log() ,但事实并非如此。

You can also "step through" .gs code. 您也可以“逐步执行” .gs代码。 There is a little picture of a bug on the menu. 菜单上有一些错误的图片。 It's often shown grayed out. 它通常显示为灰色。 And when it's grayed out, no matter what you do, you're not going to get the debug process to start. 当它变灰时,无论您做什么,都不会启动调试过程。 You need to select a function name from the drop down box first for the debug stuff to be available. 您需要首先从下拉框中选择一个函数名称,以使调试资料可用。 You can click just to the left of a line number in the code editor, and a red dot should appear to add a break point. 您可以在代码编辑器中单击行号左侧,然后会出现一个红点以添加一个断点。 Your code will stop executing at the break point and wait for you to click an icon to run the next line, or skip a line, etc. 您的代码将在断点处停止执行,并等待您单击图标以运行下一行,或跳过一行,等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从客户端脚本获取值并覆盖服务器端脚本 - Get value from client side script and override server side script 在侧边栏GAS中调用服务器端脚本 - Calling server-side script within a sidebar GAS 在Google Apps脚本中从服务器端(.gs)传递到客户端(html)时,已知类型的变量变为“未定义” - Variable of known type becomes “undefined” when passed from server side (.gs) to client-side(html) in Google Apps Script 客户端JS&服务器端C#通信 - Client-side JS & Server-side C# Communication 将 Google Apps 脚本 (GAS) - 图表服务图表传递给 GAS 中的 HTML 模板 - Pass Google Apps Script (GAS) - Charts Service chart to HTML Template within GAS 在 Google Apps 脚本中从服务器到客户端进行通信 - Communicate from server to client side in Google Apps script HTML编码服务器端vs客户端端 - HTML Encoding Server side vs Client side 从客户端将 HTML 表保存到服务器上的 CSV - Saving HTML table to CSV on server from client side 客户端javascript和C ++套接字服务器之间的通信 - Communication between client side javascript and C++ socket server 服务器端Ruby进程与客户端Javascript之间的通信 - Communication between server-side Ruby process and client Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM