代码之家  ›  专栏  ›  技术社区  ›  ledzee

在googleapp脚本中运行服务器端函数google.script.run

  •  0
  • ledzee  · 技术社区  · 7 年前

    下面是我的HTML文件在谷歌应用程序脚本。

    它在电子表格上创建一个对话框。当按下ok按钮时,我希望它运行我在应用程序脚本中创建的函数,并关闭对话框。

    谢谢。

    <!DOCTYPE html>
    <html>
    <head>
    
    <h3>Welcome</h3>
    <meta charset="utf-8">
    <title>SEOMango</title>
    <script src="http://code.jquery.com/jquery.min.js"></script>
    
    
    </head>
    <body>
    
    <input type="button" value="Ok" class="create ok_button" 
    onclick="close1();" id="ok_button"/>
    
    
    <!--JQUERY-->
    <script 
    src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">  
    </script>
    <script>
    function close1()
    {
    google.script.host.close();
    
    google.script.run.withSuccessHandler.doSomething();
    
    }
    
    </script>
    
    </body>
    </html>
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   JSmith    7 年前

    尝试以下操作:

    function close1()
    {
      google.script.run.withSuccessHandler(end).doSomething();
    }
    function end()
    {
       google.script.host.close();
    }
    

    您首先需要在google端执行您的函数 doSomething 如果成功的话 end() google.script.host.close() 在它里面关闭你的侧边栏/对话框。

    doSomething() .