gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 14:36:53 35 4
gpt4 key购买 nike

我正在尝试将对象(工作表行的内容)传递给应用程序脚本模板。您可以在屏幕截图中看到该行。

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');

记录器语句产生:
 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

这显示了“ jail 长”的一些问题。

此外,我没有看到输出到控制台的预期数据:
       console.log('row');
var myObj = JSON.parse(jsonRow);
console.log(myObj['CONVERSATION']);

我究竟做错了什么?

最佳答案

您的客户端代码从不调用 getConversations ,这就是您在控制台上看不到它的原因。在执行此操作的许多方法中,您可以通过在 <script> 之间添加以下内容来添加一个 IIFE 来调用该函数。标签

(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>

所以不是你,是谷歌

关于html - 传输或处理此请求时出错。错误代码 = 10,路径 =/wardeninit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54749441/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com