本文介绍了google.script.run不工作:未捕获InvalidArgumentError:由于属性中的非法值失败:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎有某种程度上破坏了google.run.script。我像这样调用它:

  google.script.run.withSuccessHandler(工作).verwerkForm(this.parentNode); 

在这里运行脚本时出现错误:

以前的版本运行良好,我不知道它是什么打破了代码。谷歌应用程序的脚本,当谈到错误消息或文档时,会让它变得非常烦人。如果任何人都可以提供帮助,那就太好了!



参考我也在这里提交了一个问题:



我正在使用的索引文件: p>

 > <?!= include('Stylesheet'); ?> < div class =container> < h1 
> id =PageHeader>世界篮球教练社区 -
> Inschrijving /应用与LT; / H1> < img
> SRC = https://drive.google.com/a/apps.howest.be/uc?export=view&id=0B1m3_53fwZc8cmdKYjJvakk3WDA/>
> < p id =必填> *必填< / p> < form id =form>
> < div class =special>
> < p> Aanhef< span class =required> *< / span>< / p>
> < label>< input type =radioname =voorvoegselvalue =Mrchecked /> Mr< / label>
> < label>< input type =radioname =voorvoegselvalue =Mrs/> Mrs< / label>
> < label>< input type =radioname =voorvoegselvalue =Miss/> Miss< / label>
> <跨度>< /跨度>
> < / DIV>
> < DIV>
> < label for =voornaam> Voornaam /Prénom/名字< span class =required> *< / span>< / label>
> < input type =textname =voornaamid =voornaamplaceholder =Voornaam/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =naam> Naam / Nom / Name< span class =required> *< / span>< / label>
> < input type =textname =naamid =naamplaceholder =Naam/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =geboortatum> Geboortatum / Date de naissance /出生日期< span class =required> *< / span>< / label>
> < input type =datename =geboortatumid =geboortatum/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =nationaliteit> Nationaliteit /Nationalité/ Nationaliteit< span class =required> *< / span>< / label>
> < input type =textname =nationaliteitid =nationaliteitplaceholder =Nationaliteit/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =stad> Stad / Ville / City< span class =required> *< / span>< / label>
> < input type =textname =stadid =stadplaceholder =Stad/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =land> Land / Pays / Country< span class =required> *< / span>< / label>
> < input type =textname =landid =landplaceholder =Land/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =opleiding> Opleiding / Education< span class =required> *< / span>< / label>
> < select name =opleidingid =opleiding>
> < option value =>< / option>
> < option value =中学>中学< / option>
> < option value =高中>高中< / option>
> < option value =bachelor> Bachelor< / option>
> < option value =master> Master< / option>
> < option value =university>大学< / option>
> < /选择>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =gsm> Gsm< span class =required> *< / span>< / label>
> < input type =textname =gsmid =gsmplaceholder =+ 32 000 00 00 00/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =email>电子邮件< span class =required> *< / span>< / label>
> < input type =emailname =emailid =emailplaceholder =someone@example.com/>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =passport>上传护照或ID副本(PDF或JPEG)< span class =required> *< / span>< / label>
> < input type =filename =passportaccept =image / jpeg,application / pdfid =passport>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> < label for =color_passport>上传彩色护照尺寸照片(JPEG)< span class =required> *< / span>< / label>
> < input type =filename =picaccept =image / jpegid =color_passport>
> < span class =fout>< / span>
> < / DIV>
> < div class =permission>
> < label for =akkoord>
> 世界篮球教练社区是一个国际篮联。
>世界篮球教练团体
> < span class =required> *< / span>
> < /标签>
> < section id =checkPermission>< input type =checkboxvalue =jaid =akkoord/> Ik ben akkoord< / section>
> < span class =fout>< / span>
> < / DIV>
> < DIV>
> <标签>< /标签>
> < input type =buttonvalue =Submitonclick =submit()/>
> < / DIV> < /形式> < / DIV> < div id =resultclass ='hide'>
> < / DIV> <?!= include('testJavascript'); ?>

我使用的TestJavascript:

 < script src =// ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"> ;</script> 
< script>
函数submit(){
google.script.run.withSuccessHandler(工作).verwerkForm(this.parentNode);


function worked(){
$(。container)。remove();
$(#result)。html('< h1> Dank je u u registratie is een succes!< / h1>')。removeClass('hide');
}
< / script>

和css:

 <风格> 
body {
font-family:Verdana,Arial,sans-serif;
background-image:-webkit-gradient(
线性,
左上角,
左下角,
颜色停止(0.08,#0D2C91),
color-stop(0.76,#0788B3)
);
background-image:-o-linear-gradient(bottom,#0D2C91 8%,#0788B3 76%);
background-image:-moz-linear-gradient(bottom,#0D2C91 8%,#0788B3 76%);
background-image:-webkit-linear-gradient(bottom,#0D2C91 8%,#0788B3 76%);
background-image:-ms-linear-gradient(bottom,#0D2C91 8%,#0788B3 76%);
background-image:线性渐变(至底部,#0D2C91 8%,#0788B3 76%);
}

h1#PageHeader {
margin-bottom:10px;
}

.container {
margin:0 auto;
宽度:80%;
border-left:1px纯蓝色;
border-right:1px纯蓝色;
背景:白色;
padding:10px 10px;
text-align:center;
}

。容器形式{
display:inline-block;
}

.hide {
display:none;
}

h1 {
margin:0 auto;
display:block;
}

img {
width:20%;
margin:0 auto;
display:block;
}

。需求{
颜色:#ff4444;
font-weight:400;
}

span.fout {
display:block;
颜色:#ff4444;
保证金余额:36%;
}

input.fout {
color:#ff4444;
border:1px纯红色!重要;
}

表格{
width:80%;
text-align:left;
}

表格div {
margin:10px 0;
display:block;
}

表格div标签{
box-sizing:border-box;
display:inline-block;
padding:5px;
宽度:35%;
font-weight:800;
font-family:Calibri;
}

输入,选择{
display:inline-block;
宽度:50%;
}

input [type =text],input [type =date],input [type =email],#opleiding {
padding:4px ;
font-size:14px;
line-height:1.42857143;
颜色:#555;
background-color:#fff;
background-image:none;
border:1px solid #ccc;
border-radius:4px;
box-shadow:inset 0 1px 1px rgba(0,0,0,.075);
}

#opleiding {
width:50.8%;


input [type =text],input [type =date],input [type =email] {
height:20px;
}

选择{
height:29px;
}

。特殊p {
display:inline-block;
padding:5px;
宽度:32%;
font-weight:800;
}

。特殊标签{
width:10%;
font-weight:400;
display:inline-block;
}

#checkPermission {
font-family:Calibri;
font-weight:normal;
font-size:16px;
display:inline-block;
}

。权限标签{

}

输入[type =checkbox] {
width:20px ;
}

input:focus {
border:1px solid blue;
}

input [type =button] {
color:#fff;
背景颜色:#428bca;
border-color:#357ebd;
display:inline-block;
padding:6px 12px;
margin-bottom:0;
font-size:14px;
font-weight:400;
line-height:1.42857143;
text-align:center;
white-space:nowrap;
vertical-align:middle;
光标:指针;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
background-image:none;
border:1px透明;
border-radius:4px;
}

#required {
color:#ff4444;
}
< / style>

VerwerkForm函数:

 函数verwerkForm(e){
//检查输入正确的是
var statusObject = checkInput(e);
if(!statusObject.inOrde){
Logger.log(serversidecheck mislukt);
返回false;
//抛出错误(输入不正确。); + statusObject.foutboodschappen);
}

//在变量范围内的文件操作直接在
中修改正确的文件var fileBlobP = doeSetName(e,e.passport,_passport);
var fileBlobPic = doeSetName(e,e.pic,_passport_in_color);

//创建文件
var docPass = DocsList.getFolderById(docP).createFile(fileBlobP);
var docColorPass = DocsList.getFolderById(docPic).createFile(fileBlobPic);

// maak gegevens om toe te voegen klaar,open dan de spreadsheet en voeg de rij met gegevens toe
var rijGegevens = [e.voorvoegsel,e.voornaam,e.naam,e .geboorteDatum,e.nationaliteit,e.stad,e.land,e.opleiding,e.gsm,e.email,docPass.getUrl(),docColorPass.getUrl(),new Date()];
SpreadsheetApp.openById(idSpreadsheet).getActiveSheet()。appendRow(rijGegevens);
}

解决方案
出错是因为我忘记在我的流程表单方法中包含成功案例的返回声明。一个简单的return ok在最后足以缓解这个问题。 解决方案

GAS无法传递DIV,需要发送表单,或者使用 $(#form)[0] 或者重新构建HTML,以便父按钮是形式,可以有上面的表格,但不是DIVs。


My small form-handling script seems to have somehow broken google.run.script . I invoke it like this:

google.script.run.withSuccessHandler(worked).verwerkForm(this.parentNode);

When running the script here's what i get as an error:

Previous versions were running fine and i have no clue what it is i did that broke the code. Google apps script is, to put it mildly very annoying when it comes to errormessages or documentation. If anyone can help that'd be great!

For reference i've also submitted an issue here: google script issue report

The index file i'm using:

> <?!= include('Stylesheet'); ?> <div class="container">    <h1
> id="PageHeader">World Basketball Coaches Community -
> Inschrijving/Application</h1>    <img
> src="https://drive.google.com/a/apps.howest.be/uc?export=view&id=0B1m3_53fwZc8cmdKYjJvakk3WDA"/>
> <p id="required">* required</p>    <form id="form">
>       <div class="special">
>          <p>Aanhef <span class="required">*</span></p>
>          <label><input type="radio" name="voorvoegsel" value="Mr" checked />Mr</label>
>          <label><input type="radio" name="voorvoegsel" value="Mrs"/>Mrs</label>
>          <label><input type="radio" name="voorvoegsel" value="Miss"/>Miss</label>
>          <span></span>
>       </div>
>       <div>
>          <label for="voornaam">Voornaam /Prénom /First name <span class="required">*</span></label>
>          <input type="text" name="voornaam" id="voornaam" placeholder="Voornaam"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="naam">Naam /Nom /Name <span class="required">*</span></label>
>          <input type="text" name="naam" id="naam" placeholder="Naam"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="geboortedatum">Geboortedatum/ Date de naissance/ Date of birth <span class="required">*</span></label>
>          <input type="date" name="geboortedatum" id="geboortedatum"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="nationaliteit">Nationaliteit / Nationalité / Nationaliteit <span class="required">*</span></label>
>          <input type="text" name="nationaliteit" id="nationaliteit" placeholder="Nationaliteit"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="stad">Stad / Ville / City <span class="required">*</span></label>
>          <input type="text" name="stad" id="stad" placeholder="Stad"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="land">Land / Pays / Country <span class="required">*</span></label>
>          <input type="text" name="land" id="land" placeholder="Land"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="opleiding">Opleiding/ Education <span class="required">*</span></label>
>          <select name="opleiding" id="opleiding" >
>             <option value=" "></option>
>             <option value="secondary school">Secondary school</option>
>             <option value="high school">High school </option>
>             <option value="bachelor">Bachelor</option>
>             <option value="master">Master</option>
>             <option value="university">University</option>
>          </select>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="gsm">Gsm <span class="required">*</span></label>
>          <input type="text" name="gsm" id="gsm" placeholder="+32 000 00 00 00"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="email">E-mail <span class="required">*</span></label>
>          <input type="email" name="email" id="email" placeholder="someone@example.com"/>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="passport">Upload passport or ID copy (PDF or JPEG) <span class="required">*</span></label>
>          <input type="file" name="passport" accept="image/jpeg,application/pdf" id="passport">
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label for="color_passport">Upload color passport size photo (JPEG)<span class="required">*</span></label>
>          <input type="file" name="pic" accept="image/jpeg" id="color_passport">
>          <span class="fout"></span>
>       </div>
>       <div class="permission">
>          <label for="akkoord">
>             Ik geef mijn akkoord om deze gegevens aan FIBA over te maken in het kader van de "World Basketball Coaches Community".
>             Je donne mon accord pour le transfert de mes données à la FIBA dans le cadre du projet "World Basketball Coaches Community"
> <span class="required">*</span>
>          </label>
>          <section id="checkPermission"><input type="checkbox" value="ja" id="akkoord"/> Ik ben akkoord</section>
>          <span class="fout"></span>
>       </div>
>       <div>
>          <label></label>
>          <input type="button" value="Submit" onclick="submit()"/>
>       </div>    </form> </div> <div id="result" class='hide'>
>     </div> <?!= include('testJavascript'); ?>

TestJavascript i'm using:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function submit() {
      google.script.run.withSuccessHandler(worked).verwerkForm(this.parentNode);
}

function worked() {
   $(".container").remove();
   $("#result").html('<h1>Dank je uw registratie is een succes!</h1>').removeClass('hide');
}
</script>

and the css:

<style>
body {
   font-family: Verdana,Arial,sans-serif;
   background-image: -webkit-gradient(
      linear,
      left top,
      left bottom,
      color-stop(0.08, #0D2C91),
      color-stop(0.76, #0788B3)
   );
   background-image: -o-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
   background-image: -moz-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
   background-image: -webkit-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
   background-image: -ms-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
   background-image: linear-gradient(to bottom, #0D2C91 8%, #0788B3 76%);
}

h1#PageHeader {
   margin-bottom:10px;
}

.container {
   margin: 0 auto;
   width: 80%;
   border-left: 1px solid blue;
   border-right: 1px solid blue;
   background: white;
   padding: 10px 10px;
   text-align:center;
}

.container form{
   display:inline-block;
}

.hide{
   display: none;
}

h1 {
   margin: 0 auto;
   display: block;
}

img {
   width: 20%;
   margin: 0 auto;
   display: block;
}

.required {
   color: #ff4444;
   font-weight: 400;
}

span.fout {
   display:block;
   color : #ff4444;
   margin-left: 36%;
}

input.fout {
   color : #ff4444;
   border: 1px solid red !important;
}

form {
   width:80%;
   text-align:left;
}

form div {
   margin: 10px 0;
   display: block;
}

form div label {
   box-sizing: border-box;
   display: inline-block;
   padding: 5px;
   width: 35%;
   font-weight: 800;
   font-family: Calibri;
}

input, select {
   display: inline-block;
   width: 50%;
}

input[type="text"], input[type="date"], input[type="email"], #opleiding {
   padding: 4px;
   font-size: 14px;
   line-height: 1.42857143;
   color: #555;
   background-color: #fff;
   background-image: none;
   border: 1px solid #ccc;
   border-radius: 4px;
   box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
}

#opleiding {
   width: 50.8%;
}

input[type="text"], input[type="date"], input[type="email"]{
   height: 20px;
}

select{
   height:29px;
}

.special p {
   display: inline-block;
   padding: 5px;
   width: 32%;
   font-weight: 800;
}

.special label {
   width: 10%;
   font-weight: 400;
   display: inline-block;
}

#checkPermission {
   font-family: Calibri;
   font-weight:normal;
   font-size: 16px;
   display: inline-block;
}

.permission label {

}

input[type="checkbox"]{
   width: 20px;
}

input:focus {
   border :1px solid blue;
}

input[type="button"] {
   color: #fff;
   background-color: #428bca;
   border-color: #357ebd;
   display: inline-block;
   padding: 6px 12px;
   margin-bottom: 0;
   font-size: 14px;
   font-weight: 400;
   line-height: 1.42857143;
   text-align: center;
   white-space: nowrap;
   vertical-align: middle;
   cursor: pointer;
   -webkit-user-select: none;
   -moz-user-select: none;
   -ms-user-select: none;
   user-select: none;
   background-image: none;
   border: 1px solid transparent;
   border-radius: 4px;
}

#required {
   color: #ff4444;
}
</style>

The VerwerkForm function:

 function verwerkForm(e){
   //check of alle input correct is
   var statusObject = checkInput(e);
   if(!statusObject.inOrde){
     Logger.log("serversidecheck mislukt");
     return false;
//     throw Error("De input is niet correct.  Volgende fouten werden gevonden: " + statusObject.foutboodschappen);
   }

   //sla de files in variabelen op en stel direct ook hun naam correct in
   var fileBlobP = doeSetName(e, e.passport, "_passport");
   var fileBlobPic = doeSetName(e, e.pic, "_passport_in_color");

   //creating files
   var docPass = DocsList.getFolderById(docP).createFile(fileBlobP);
   var docColorPass = DocsList.getFolderById(docPic).createFile(fileBlobPic);

   //maak gegevens om toe te voegen klaar, open dan de spreadsheet en voeg de rij met gegevens toe
   var rijGegevens = [e.voorvoegsel, e.voornaam, e.naam, e.geboorteDatum, e.nationaliteit, e.stad, e.land, e.opleiding, e.gsm, e.email, docPass.getUrl(), docColorPass.getUrl(), new Date()];
   SpreadsheetApp.openById(idSpreadsheet).getActiveSheet().appendRow(rijGegevens);
}

SOLUTIONThe error turned out to be because i forgot to include a return statement for the successful case in my process form method. A simple "return ok" at the end was enough to alleviate the problem.

解决方案

GAS can't pass on DIVs, you need to send in the form, either use $( "#form" )[0] or restructure your HTML so that the button parent is the form, there can be tables above it but not DIVs.

这篇关于google.script.run不工作:未捕获InvalidArgumentError:由于属性中的非法值失败:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:33
查看更多