以下联系表格http://wearedappr.com/contact.html在提交后将所有信息发送到google电子表格。但是,它还会将用户重定向到https://script.googleusercontent.com(请参见下图)
我正在尝试显示确认消息,而不是重定向消息。例如“感谢您与我们联系!我们会尽快与您联系!”一旦我们提交,它将显示在联系表单页面上。
有人可以帮忙吗?
这是form-submission-handler.js: http://wearedappr.com/form-submission-handler.js
答案 0 :(得分:1)
尝试这些。
1,将您的开始表格标签更改为此:
<form class="gform pure-form pure-form-stacked" id="google_form_submit">
2,将以下内容添加到您的代码中,位于结束body标签之前
<script type="text/javascript">
$('#google_form_submit').submit(function(e){
e.preventDefault();
var formData = $('#google_form_submit').serialize();
$.ajax({
type : 'POST',
url : 'https://script.google.com/macros/s/AKfycbzBvgWZZUgFbxCAlhPG4429wth61Rm7kymPaui3d5328UHHOiA/exec',
data : formData,
dataType : 'json',
encode : true
}).done(function(data) {
if(data.result == 'success') {
// Form submission was successful and accepted by google.
// You can show your success message here
} else {
// Form was submission failed for some reasons.
// You can examine the response from google to see whats missing
}
}).fail(function (jqXHR,status,err) {
// Form submission failed due to some network or other errors
// I am alerting the error but you can do anything else with it
alert(err);
});
});
</script>
请原谅我不整洁的代码...我正在通过平板电脑发布答案。 如果您发现任何错误,请通知我,以便我解决