karnov.club/js/form-handling.js

30 lines
631 B
JavaScript
Raw Normal View History

2015-12-25 01:47:55 +00:00
/*
* Contact form handling using AJAX, sends request to Formspree.io
*/
2015-12-25 01:10:57 +00:00
var $contactForm = $('#contactme');
$contactForm.submit(function(e) {
e.preventDefault();
$.ajax({
url: '//formspree.io/c.marcandre@gmail.com',
method: 'POST',
2015-12-25 01:17:39 +00:00
data: {
Sender: $("#sender").val(),
Position: $("#function").val(),
Email: $("#replyto").val(),
Details: $("#details").val()
},
2015-12-25 01:10:57 +00:00
dataType: 'json',
beforeSend: function() {
2015-12-25 01:14:05 +00:00
console.log("Sending.");
2015-12-25 01:10:57 +00:00
},
success: function(data) {
2015-12-25 01:49:34 +00:00
$('#contactme').trigger("reset");
2015-12-25 01:47:55 +00:00
$("#contact-popup").fadeIn();
2015-12-25 01:10:57 +00:00
},
error: function(err) {
2015-12-25 01:14:05 +00:00
console.log("Failed.");
2015-12-25 01:10:57 +00:00
}
});
});