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

传输或处理此请求时出错。错误代码=10,路径=/WARDENIT

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

    enter image description here

    应用程序脚本中的我的函数包含:

    var sendableRows = rows.filter(function (row) { //ONLY CHECKED ROWS.
      return row['Index'] == true;
    });  
    var sendableRow = sendableRows[0];
    Logger.log('sendableRow '+ JSON.stringify( sendableRow));
    
    var html = HtmlService.createTemplateFromFile('RowPopup');
    html.row = JSON.stringify(sendableRow);
    var h =html.evaluate();
    
    SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showModalDialog(h, 'Create Documents');
    

    logger语句生成:

     sendableRow {"Index":true,"Timestamp":"2019-02-12T21:09:14.000Z","FROM":222222,"CONVERSATION":"THIS IS A TEST","ME":"","relativeRow":14,"absoluteRow":15}
    

    我的Rowpopup.html是:

    <!DOCTYPE html>
    <html>
    <head>
      <base target="_top">
      <script>
        // Prevent forms from submitting.
        function preventFormSubmit() {
          var forms = document.querySelectorAll('forms');
          for (var i = 0; i < forms.length; i++) {
            forms[i].addEventListener('submit', function(event) {
              event.preventDefault();
            });
          }
        }
        window.addEventListener('load', preventFormSubmit);
    
        function handleFormSubmit(formObject) {
          // the output from form goes to processDocBuildHtml
          google.script.run
              .withSuccessHandler(updateUrl)
              .processRowPopupHTML(formObject);
        }
    
        function updateUrl(url) {
          var div = document.getElementById('output');
          div.innerHTML = '<a href="' + url + '">Sent!</a>';
        }
      </script>
    </head>
    
    <body>
      <form id="myForm" onsubmit="handleFormSubmit(this)">
    
        <div>
          <label for="optionList">Click me</label>
          <select id="optionList" name="email">
            <option>Loading...</option>    
          </select>
        </div>
    
        <br>
        <div>
        </div>
    
        <br>
        <div>
          <textarea name="message" rows="10" cols="30">
    The cat was playing in the garden.
          </textarea>
        </div>
        <div id="textboxes"></div>
    
        <div id="insert"></div>
    
        <input type="submit" value="Submit" />
      </form>
    
      <div id="output">
      </div>
    
      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
      <script src="//rawgithub.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.js"></script>
      <link href="//rawgithub.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.css" rel="stylesheet">
    
      <script>
      function getConversations() {
        var jsonRow = <?= row ?>; //PASSED IN JSON
        console.log('row');
        var myObj = JSON.parse(jsonRow);
        console.log(myObj['CONVERSATION']);
    
        return myObj['CONVERSATION'];
      }
      </script>
    </body>
    

    enter image description here

    这表明“典狱长”有些问题。

    此外,我没有看到在以下情况下输出到控制台的预期数据:

           console.log('row');
           var myObj = JSON.parse(jsonRow);
           console.log(myObj['CONVERSATION']);
    

    0 回复  |  直到 7 年前
        1
  •  10
  •   Wicket    7 年前

    您的客户端代码从不调用 getConversations ,这就是为什么在控制台上看不到它的原因。在许多方法中,您可以添加一个IIFE来调用该函数,方法是在 <script>

    (function (){getConversations()}());
    


    另一方面,Chrome开发者工具控制台上出现的错误消息即使是最简单的代码也会出现,如下所示
    function myFunction(){
      var html = HtmlService.createHtmlOutputFromFile('index');
      SpreadsheetApp.getUi().showModalDialog(html, 'Test')
    }
    
    <!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
        Hello world!
      </body>
    </html>
    

    所以不是你,是谷歌

        2
  •  1
  •   TheMaster    7 年前

    您只声明了函数 getConversations . 直到调用它才执行它 () .

    (function getConversations(){})()
    
        3
  •  1
  •   harukaeru    5 年前

    我知道这个答案与这篇文章无关,我应该发布的位置也不合适,但是对于以后到达这个页面的其他人,我在这里留下了一个答案,因为我很难解决类似的问题。

    我认为这个错误意味着我们无法从HTML文件连接到脚本编辑器中编写的脚本。

    google.script.run.myFunction() . 所以,首先,我认为这个错误阻止了这个执行。但是,该错误与此执行完全无关。这是另一个问题,我通过使用 withFailureHandler(onFailure) https://stackoverflow.com/a/33008218/3077059 )

    正如鲁本先生所说,“所以不是你,是谷歌”,这个错误可以很容易地重演。请不要对这条消息感到困惑。我认为,错误消息(“传输或处理此请求时出错。错误代码=10,路径=/wardeninit”)是无用的。 https://stackoverflow.com/a/54756933/3077059

        4
  •  0
  •   Rodrigo Salinas    6 年前

    我也有类似的问题。但就我而言,我的大多数用户都没有这个问题。然后我发现,在这些情况下(大约10%),如果他们安装Firefox并运行应用程序,一切都正常。这就是我的解决方案:在出现这种行为时建议Firefox。

        5
  •  0
  •   sɐunıɔןɐqɐp Zmey    5 年前

    我的解决方案:使用库脚本的版本化部署。

    我有一个类似的问题,我无法运行我自己的功能从侧栏在谷歌表。这个问题似乎与使用库有关,尽管我试图执行的脚本并不依赖于库。

    当库连接到容器脚本时,我无法执行侧栏中的函数。当我拆除图书馆时,一切正常。我使用的是图书馆的head版本,这意味着最新的发展。我决定尝试管理部署和创建项目的版本。我添加了一个库部署和版本,然后更新了我的库引用,一切都恢复了正常。

    参考资料:

    Why does my apps script deployed as API executable return Permission Denied?

    https://developers.google.com/apps-script/concepts/deployments