$("form").each(function() {
$(this).submit(function() {
var action = $(this).attr('action');
$.ajax({
url: action,
type: 'POST',
data: {
contactemail: $(this).find('input[type=email]').val()
},
success: function() {
$(this).closest(".section").find(".bg_form_submit").slideToggle("slow");
alert ("1");
$('form').trigger('reset');
},
error: function() {
alert ("0");
}
});
return false;
});
});
$("form").each(function(i, el) {
$(el).submit(function() {
let $that = $(this); // var $that = $(this); - для ES5
$.ajax({
url: $that.attr('action'),
type: 'POST',
data: {
contactemail: $that.find('input[type=email]').val()
},
success: function() {
$that.closest(".section").find(".bg_form_submit").slideToggle("slow");
alert("1");
$('form').trigger('reset');
},
error: function() {
alert("0");
}
});
return false;
});
});