window.addEventListener("DOMContentLoaded", (event) => { $(".t_contactForm, .e_contactForm, .loc_contactForm, .c_contactForm").submit(function(e) { e.preventDefault(); var form = $(this); var offerType = $(this).data("type"); //var actionUrl = form.attr('action'); var actionUrl = "/mailing/mail.php?type=" + offerType; $.ajax({ type: "POST", url: actionUrl, data: form.serialize(), //contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { //console.log(data); if(data.isSuccessful == true){ Swal.fire({ title: 'Başarılı!', text: data.message, icon: 'success', confirmButtonText: 'Tamam!', //timer: 2000, customClass: { confirmButton: 'btn' }, buttonsStyling: false }); }else{ Swal.fire({ title: 'Hata!', html: '
'+data.message+'
saniye içinde kapanıyor...
', icon: 'error', confirmButtonText: 'Tamam', timer: 3000, customClass: { confirmButton: 'btn-main btn-eighteen' }, buttonsStyling: false, didOpen: () => { const content = Swal.getHtmlContainer(); const $ = content.querySelector.bind(content); //Swal.showLoading(); timerInterval = setInterval(() => { Swal.getHtmlContainer().querySelector('strong') .textContent = (Swal.getTimerLeft() / 1000) .toFixed(0) }, 100); }, willClose: () => { clearInterval(timerInterval); } }); } }, error: function (errMsg) { /*alert(errMsg); console.log(errMsg)*/ }, complete: function() { //form.find('*[type="submit"]').prop("disabled", true); form.trigger("reset"); $('.modal').modal('hide'); } }); }); $(".club_contactForm").submit(function(e) { e.preventDefault(); var form = $(this); //var actionUrl = form.attr('action'); var actionUrl = "/mailing/club-mail.php"; $.ajax({ type: "POST", url: actionUrl, data: form.serialize(), //contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { //console.log(data); if(data.isSuccessful == true){ Swal.fire({ title: 'Başarılı!', text: data.message, icon: 'success', confirmButtonText: 'Tamam!', //timer: 2000, customClass: { confirmButton: 'btn' }, buttonsStyling: false }); form.trigger("reset"); $('.modal').modal('hide'); }else{ Swal.fire({ title: 'Hata!', html: ''+data.message+'
saniye içinde kapanıyor...
', icon: 'error', confirmButtonText: 'Tamam', timer: 3000, customClass: { confirmButton: 'btn' }, buttonsStyling: false, didOpen: () => { const content = Swal.getHtmlContainer(); const $ = content.querySelector.bind(content); //Swal.showLoading(); timerInterval = setInterval(() => { Swal.getHtmlContainer().querySelector('strong') .textContent = (Swal.getTimerLeft() / 1000) .toFixed(0) }, 100); }, willClose: () => { clearInterval(timerInterval); } }); } }, error: function (errMsg) { /*alert(errMsg); console.log(errMsg)*/ }, complete: function() { //form.find('*[type="submit"]').prop("disabled", true); /*form.trigger("reset"); $('.modal').modal('hide');*/ } }); }); });