-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cf7b26
commit 26b6bdf
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,7 @@ <h3>Indianapolis, IN</h3> | |
</div> | ||
<div class="col-md-6"> | ||
<form | ||
id="contact-form" | ||
action="https://formspree.io/f/mleqweqd" | ||
method="POST"> | ||
|
||
|
@@ -261,6 +262,37 @@ <h3>Indianapolis, IN</h3> | |
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.0.min.js"><\/script>')</script> | ||
|
||
<script> | ||
var form = document.getElementById("contact-form"); | ||
|
||
async function handleSubmit(event) { | ||
event.preventDefault(); | ||
var data = new FormData(event.target); | ||
fetch(event.target.action, { | ||
method: form.method, | ||
body: data, | ||
headers: { | ||
'Accept': 'application/json' | ||
} | ||
}).then(response => { | ||
// $('.alert').remove(); | ||
if (response.ok) { | ||
$('.jumbotron .container').prepend("<div class='alert alert-thanks' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>Thank you for contacting The Able Few. Someone will be back with you shortly!</div>"); | ||
form.reset() | ||
} else { | ||
response.json().then(data => { | ||
if (Object.hasOwn(data, 'errors')) { | ||
$('.jumbotron .container').prepend("<div class='alert alert-thanks' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>" + data["errors"].map(error => error["message"]).join(", ") + "</div>"); | ||
} else { | ||
$('.jumbotron .container').prepend("<div class='alert alert-thanks' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>There was a problem submitting your request. Give us a call or send us an email: [email protected]</div>"); | ||
} | ||
}) | ||
} | ||
}).catch(error => { | ||
$('.jumbotron .container').prepend("<div class='alert alert-thanks' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>There was a problem submitting your request. Give us a call or send us an email: [email protected]</div>"); | ||
}); | ||
} | ||
form.addEventListener("submit", handleSubmit) | ||
|
||
function getQueryVariable(variable) | ||
{ | ||
var query = window.location.search.substring(1); | ||
|