错误 HTML 联系表单在提交后重定向到 script.googleusercontent.com
Bad HTML contact form redirecting to script.googleusercontent.com after submission
以下联系方式http://wearedappr.com/contact.html send all informations to a google spreadsheet after submitting. However, it also redirects the user to https://script.googleusercontent.com(见下图)
我正在尝试显示确认消息而不是重定向。类似 "Thanks for contacting us! We will get back to you soon!" 的内容会在我们提交后出现在联系表单页面上。
有人可以帮忙吗?
这是表单提交-handler.js:
http://wearedappr.com/form-submission-handler.js
试试这些。
1,将您的开始表单标签更改为:
<form class="gform pure-form pure-form-stacked" id="google_form_submit">
2、将以下内容添加到您的代码中,在结束正文标记之前
<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>
请原谅我不整洁的代码...我正在从平板电脑上发布答案。
如果您发现任何问题,请告诉我,以便我解决
以下联系方式http://wearedappr.com/contact.html send all informations to a google spreadsheet after submitting. However, it also redirects the user to https://script.googleusercontent.com(见下图)
我正在尝试显示确认消息而不是重定向。类似 "Thanks for contacting us! We will get back to you soon!" 的内容会在我们提交后出现在联系表单页面上。
有人可以帮忙吗?
这是表单提交-handler.js: http://wearedappr.com/form-submission-handler.js
试试这些。
1,将您的开始表单标签更改为:
<form class="gform pure-form pure-form-stacked" id="google_form_submit">
2、将以下内容添加到您的代码中,在结束正文标记之前
<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>
请原谅我不整洁的代码...我正在从平板电脑上发布答案。 如果您发现任何问题,请告诉我,以便我解决