我已经使用emailJS.com创建联系表格。表单正在使用以下代码:
<script type="text/javascript">
window.onload = function () {
document.getElementById('contact-form').addEventListener('submit',function (event) {
event.preventDefault();
emailjs.sendForm('gmail2','filtrastop',this);
document.getElementById('contact-form').reset();
});
document.getElementById('form2').addEventListener('submit',this);
document.getElementById('form2').reset();
});
}
</script>
我正在尝试添加确认/错误消息,该消息会在提交表单时显示给用户。阅读文档(https://www.emailjs.com/docs/sdk/send-form/)
之后我的代码现在看起来像这样,但是我没有看到任何消息吗?请帮忙!
<script type="text/javascript">
window.onload = function () {
document.getElementById('contact-form').addEventListener('submit',this).then(function (response) {
console.log('SUCCESS!',response.status,response.text);
},function (error) {
console.log('FAILED...',error);
});
document.getElementById('contact-form').reset();
});
document.getElementById('form2').addEventListener('submit',function (event) {
console.log('SUCCESS!',response.text);
},function (error) {
console.log('FAILED...',error);
});
}
</script>