A
A
Artyom Tsymbalyuk2018-03-12 03:59:36
JavaScript
Artyom Tsymbalyuk, 2018-03-12 03:59:36

How to display a modal window after pressing the "submit" button?

Hello
There is a form handler script that, after successful data transfer to the server, displays an alert with some text
. How can I make it display a magnific popup window instead of a window?

$("form").submit(function() { //Change
var th = $(this);
$.ajax({
  type: "POST",
  url: "mail.php", //Change
  data: th.serialize()
}).done(function() {
alert("Thank you!");
setTimeout(function() {
// Done Functions
th.trigger("reset");
  }, 1000);
});
return false;
});

<div id="succes" class="zoom-anim-dialog mfp-hide">
  <h3>Ваша заявка успешно отправлена!</h3>
</div>

The Magnific Popup library itself

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tyzberd, 2018-03-12
@artlivee

add instead of alert("Thank you!");

$.magnificPopup.open({
  items: {
    src: '#succes',
    type: 'inline'
  }
});

https://codepen.io/anon/pen/XEmMmR

D
Denis, 2018-03-12
@sidni

Well, instead of alert write

$('form').append('<div id="succes" class="zoom-anim-dialog mfp-hide">
  <h3>Ваша заявка успешно отправлена!</h3>
</div>');

A After the line // Done Functions
$('#succes').remove();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question