Skip to content

Commit

Permalink
Test 404 forms (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeSCahill authored Apr 25, 2023
1 parent 6844b20 commit c0ef1fb
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/partials/form-404.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ var url = document.getElementById('url');
var date = document.getElementById('date');
url.value = window.location.href;
date.value = new Date();
form.submit(function (e) {
e.preventDefault();
const formData = new FormData(e.target)
const handleSubmit = (e) => {
e.preventDefault();
const formData = new FormData(e.target)
fetch("/", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(formData).toString(),
}).then(() => {
console.log('Form submission success')
})
.catch(error => {
console.error('Form submission error:', error)
})
})
fetch("/", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(formData).toString(),
}).then(() => {
console.log('Form submission success')
})
.catch(error => {
console.error('Form submission error:', error)
})
}
form.addEventListener('submit', handleSubmit)
document.getElementById('submit-button').click();
</script>

0 comments on commit c0ef1fb

Please sign in to comment.