Submit Form via Ajax and report Errors

This commit is contained in:
MaZderMind 2015-03-31 16:36:36 +02:00
parent 5c80bf0c03
commit a0c939e003
3 changed files with 19 additions and 3 deletions

View file

@ -116,7 +116,8 @@ body.e500 {
}
body.feedback {
.feedback-thankyou {
.feedback-thankyou,
.feedback-error {
font-size: @jumbo-font-size;
text-align: center;
padding: 30px;

View file

@ -380,9 +380,23 @@ $(function() {
// feedback form
$(function() {
$('.feedback-form').on('submit', function() {
$('.feedback-form').on('submit', function(e) {
e.preventDefault();
var $form = $(this);
$('.feedback-form').hide();
$('.feedback-thankyou').show();
$.ajax({
url: $form.prop('action'),
method: $form.prop('method'),
data: $form.serialize(),
success: function() {
$('.feedback-thankyou').show();
},
error: function() {
$('.feedback-error').show();
}
});
});
});

View file

@ -144,4 +144,5 @@
</form>
<h3 class="feedback-thankyou">Thank you!</h3>
<h3 class="feedback-error">The Feedback seems to be also broken…</h3>
<iframe name="feedback-target" style="display: none;"></iframe>