Hello, such a problem. There is a form, after sending which and receiving a response from the server, a window should pop up. the form works, but there is no window, what could be the reason?
... <input type="submit" name="submit" class="buton" id="buton"> </form> <div class="overlay js-overlay-thank-you"> <div class="popup js-thank-you"> <h2>Спасибо за заявку. Мы свяжемся с вами в ближайшее время!</h2> <div class="close-popup js-close-thank-you"></div> </div> </div> Popup Styles
.overlay { position: absolute; height: 100vh; width: 100%; top: 0; left: 0; background-color: rgba(0,0,0,0.5); display: none; } .popup{ position: absolute; width: 300px; height: 180px; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); padding: 40px; background-color: #fff; } .close-popup{ position: absolute; top: 15px; right: 15px; width: 23px; height: 23px; cursor: pointer; } .close-popup:before { content: " "; background-color: #000; position: absolute; top: 11px; left: -4px; width: 31px; height: 3px; -webkit-transform: rotate(-45deg); -ms-transform: rotate(-45deg); transform: rotate(-45deg); } .close-popup:after { content: " "; background-color: #000; position: absolute; top: 11px; left: -4px; width: 31px; height: 3px; -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } And the script
$(document).ready(function() { $("#form").submit(function(e){ e.preventDefault(); if(document.getElementById('form').name.value == '' || document.getElementById('form').email.value == '' || document.getElementById('form').phone.value == ''){ valid = false; return valid; } $.ajax({ type: "POST", url: "mail.php", data: $(this).serialize(), success: function(data){ $(".overlay").fadeIn(); $(this).find("input").val(''); $("#form").trigger("reset"); }, error: function(jqXHR, exception) { console.log(jqXHR); console.log(exception); } }); return; }); }); //закрыть форму $(".close-popup").click(function() { $(".overlay").fadeOut(); }); $(document).mouseup(function (e) { var popup = $(".popup"); if (e.target!=popup[0]&&popup.has(e.target).length === 0){ $(".overlay").fadeOut(); } });
по отправлению, and notпо получению ответа сервера? - Dmytrykmail.phpscript - it probably does not return an answer. - yar85$(this).find("input").val('');- what isthishere? - Igor