|
|
|
|
@ -44,25 +44,32 @@ $(document).ready(function(){ |
|
|
|
|
$("form.popup-form").on("submit", function(e){ |
|
|
|
|
console.log('11'); |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var $this = $(this), |
|
|
|
|
url = $this.attr("action"), |
|
|
|
|
form = $this.serialize(); |
|
|
|
|
$.post( |
|
|
|
|
url, |
|
|
|
|
form, |
|
|
|
|
function(data){ |
|
|
|
|
console.log(data); |
|
|
|
|
if(data.success){ |
|
|
|
|
// show thanks popup
|
|
|
|
|
$('.popup__close').click(); |
|
|
|
|
$('.overlay').fadeIn(400, |
|
|
|
|
function () { |
|
|
|
|
$('.popup-thank') |
|
|
|
|
.css('display', 'block') |
|
|
|
|
.animate({opacity: 1}, 200); |
|
|
|
|
}); |
|
|
|
|
var $form = $(this), |
|
|
|
|
url = $form.attr("action"), |
|
|
|
|
data = $form.serialize(), |
|
|
|
|
type = $form.attr('method'); |
|
|
|
|
|
|
|
|
|
$form.find('.error').removeClass('error'); |
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
url: url, |
|
|
|
|
type: type, |
|
|
|
|
data: data, |
|
|
|
|
success: function(data){ |
|
|
|
|
if (data.success) { |
|
|
|
|
$form.parents('.popup').fadeOut(200, function() { |
|
|
|
|
$('.popup-thank') |
|
|
|
|
.css('display', 'block') |
|
|
|
|
.animate({opacity: 1}, 200); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (data.errors) { |
|
|
|
|
$.each(data.errors, function(i, val) { |
|
|
|
|
$form.find('input[name="' + i + '"]').addClass('error') |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|