From a0c939e003dc52cf1f7858e1418ed281f15c37cc Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Tue, 31 Mar 2015 16:36:36 +0200 Subject: Submit Form via Ajax and report Errors --- assets/css/_structure.less | 3 ++- assets/js/lustiges-script.js | 18 ++++++++++++++++-- template/assemblies/feedback.phtml | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/assets/css/_structure.less b/assets/css/_structure.less index 5de12e0..a465bad 100644 --- a/assets/css/_structure.less +++ b/assets/css/_structure.less @@ -116,7 +116,8 @@ body.e500 { } body.feedback { - .feedback-thankyou { + .feedback-thankyou, + .feedback-error { font-size: @jumbo-font-size; text-align: center; padding: 30px; diff --git a/assets/js/lustiges-script.js b/assets/js/lustiges-script.js index ef685d0..447341f 100644 --- a/assets/js/lustiges-script.js +++ b/assets/js/lustiges-script.js @@ -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(); + } + }); + }); }); diff --git a/template/assemblies/feedback.phtml b/template/assemblies/feedback.phtml index 3c29cfb..8476dee 100644 --- a/template/assemblies/feedback.phtml +++ b/template/assemblies/feedback.phtml @@ -144,4 +144,5 @@

Thank you!

+

The Feedback seems to be also broken…

-- cgit v1.2.3