Created
April 8, 2018 22:59
-
-
Save haydencarlson/fd3a9717df06cadc34bcde5ac8518c85 to your computer and use it in GitHub Desktop.
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
<style> | |
.formSuccess { | |
color: green; | |
} | |
.formError { | |
color: #bf0000; | |
} | |
</style> | |
<script type="text/javascript"> | |
$(function() { | |
$('#send-contact-email').on('click', function(e) { | |
var formdata = $('#contacts').serialize(); | |
$.ajax({ | |
url: '{PATH_TO}/contact.php', | |
data: formdata, | |
method: 'POST' | |
}).then(function(response) { | |
console.log(response) | |
$('.contactFormMessage').removeClass("formSuccess"); | |
$('.contactFormMessage').removeClass("formError"); | |
var parsedResponse = JSON.parse(response); | |
$('.contactFormMessage').addClass(parsedResponse.style); | |
$('.contactFormMessage').text(parsedResponse.message); | |
}); | |
}); | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment