A
A
a700pa2021-08-17 12:33:56
AJAX
a700pa, 2021-08-17 12:33:56

Why doesn't the message about successful data sending work?

The data is successfully sent to the mail and the form is cleared. But the message about sending data is not displayed.
Please tell me where is the mistake.

html code on the page:

<form id="form1" action="#" class="feedback-form">
<input class="input" type="text" name="name" placeholder="Ваше имя" required>
<input class="input" type="tel" name="tel" placeholder="Ваш телефон" required>
<button type="submit" class="btn1">Отправить</button>
<span>Нажимая кнопку «Отправить» вы соглашаетесь на обработку персональных данных.</span>
</form>
<div class="hidden">
<div class="pop" id="pop">
Спасибо за обращение! <br> Заявка отправлена.
</div>
</div>


script
// Маска для формы телефона
    $("input[type='tel']").inputmask({"mask": "+7 (999) 999-9999"});
    // <input type="tel" placeholder="+7 (___) ___-___" name="tel">


  //Аякс отправка форм
  //Документация: http://api.jquery.com/jquery.ajax/
  $(document).ready(function () {
    $("#form1").submit(function () {
        $.ajax({
            type: "POST"
            , url: "mail.php"
            , data: $(this).serialize()
        }).done(function () {
            $(this).find("input").val("");
            $("#form1").trigger("reset");
            $.fancybox.open($("#pop"));
            setTimeout(function () {
                $.fancybox.close();
            }, 1500);
        });
        return false;
    });
  });


css form code about successful submission
.pop {
  background-color: #fff;
  max-width: 300px;
  width: 95%;
  text-align: center;
  padding: 40px 15px;
  border-radius: 5px;
  font-size: 24px;
}

.pop .fancybox-close-small {
  display: none;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Red_Devi1, 2021-08-17
@Red_Devi1

There is no desire to understand fancybox. Replace $.fancybox.open($("#pop"));with $("#pop").show();or open the console and examine the contents for errors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question