我想將表單回覆發送給Google工作表,然後將用戶重定向到感謝頁面。 Google腳本將用戶直接重定向到報告頁面。我想放棄谷歌重定向並將我的地方。使用ajax重定向表單提交
形式:
<form method="post" id="formID" action="gscript">
...
</form>
腳本:
<script>
$(document).on('submit', '.formID', function(e) {
$.ajax({
url: $(this).attr('action'),
type: $(this).attr('method'),
data: $(this).serialize(),
success: function(html) {
alert('ok');
window.location("Thanks page link");
}
});
e.preventDefault();
});
</script>
不應該'.formID'是'#formID'? – manelgarcia
對,它應該x) – Kapparina
仍然無法正常工作。 :( – David