You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
template-for-verstka/send/ajax.js

29 lines
771 B

jQuery(document).ready(function () {
jQuery('form').submit(function () {
var formID = jQuery(this).attr('id')
var formNm = jQuery('#' + formID)
formNm.addClass('sending')
jQuery.ajax({
type: 'POST',
url: 'send/send.php',
data: formNm.serialize(),
dataType: 'json',
success: function (data, jqXHR) {
if (data.result == 'success') {
setTimeout(() => {
formNm.removeClass('sending')
jQuery('section.modal.opened').removeClass('opened')
jQuery('#modal__bg').addClass('opened')
jQuery('section.modal[data-id="success"]').addClass('opened')
}, 1000)
}
},
error: function (jqXHR, text, error) {
console.log('ошибка')
console.log(jqXHR)
console.log(error)
},
})
return false
})
})