繁体   English   中英

个人HTML表单到Google表格

[英]Personal HTML Form to Google Sheets

我正在调查网页( http://ordrespontane.blogspot.com/2018/01/html-form-to-google-sheet.html )上有关如何将google表格连接到非google的网络表格的信息。 我按照指示进行,但是,对我来说似乎无济于事。 有没有其他人使用它并获得成功? 我还注意到,我的姓名和信息一旦插入表格,就不会消失。 那是正常的吗?

 <!DOCTYPE html> <head><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script></head> <body> <form id="myForm" action="https://script.google.com/macros/s/AKfycbxRtG9fv7vE14yZR8_46YQrqC76wkDvHqT88ArBmeriPlPc4aB6/exec"> First Name:<br> <input type="text" name="firstname" style="width:200px"><br> Last Name:<br> <input type="text" name="lastname" style="width:200px"><br> <br> <input type="submit" id="mySubmit" value="Submit"> </form> <p><span id="myConf">This is where the confirmation message will appear after submission.</span></p> <script type="text/javascript"> $(document).ready(function(){ // References: var $form = $('#myForm'); var $conf = $('#myConf'); var $subm = $('#mySubmit'); var $impt = $form.find(':input').not(':button, :submit, :reset, :hidden'); // Submit function: $form.submit(function(){ $.post($(this).attr('action'), $(this).serialize(), function(response){ // On success, clear all inputs; $impt.val('').attr('value','').removeAttr('checked').removeAttr('selected'); // Write a confirmation message: $conf.html("Submitted!"); // Disable the submit button: $subm.prop('disabled', true); },'json'); return false; }); }); </script> </body> </html> 

跨域资源共享(CORS)是一种防止发送表单的机制。 浏览器不允许您向其他站点发出HTTP请求,而不是从该站点加载该站点。 我猜您正在PC的html页面上对其进行测试。

要允许脚本请求,您必须为此特定页面添加HTTP标头Web服务器

Access-Control-Allow-Origin: https://script.google.com

要么

Access-Control-Allow-Origin: *

或者,您可以使用浏览器插件为您完成此操作(如本示例 )。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM