P
P
Pavel2017-05-31 21:30:41
JavaScript
Pavel, 2017-05-31 21:30:41

How to make a popup window after submitting a form?

$("#form1").submit(function () { 
        var th = $(this);
        $.ajax({
            type: "POST",
            url: "mail.php", //Change
            data: th.serialize()
        }).done(function () {
            // код после успешной отправки формы
        });
        return false;
    });

I need to call #tnx in fancybox , I don't understand how to do it,
this option doesn't work
$("#form1").submit(function () { 
        var th = $(this);
        $.ajax({
            type: "POST",
            url: "mail.php", //Change
            data: th.serialize()
        }).done(function () {
            // код после успешной отправки формы
$.fancybox({
        href: '#thx',
        openEffect: 'elastic',
        closeEffect: 'elastic',
        afterLoad: function() {
          setTimeout(function() {
            parent.$.fancybox.close({
              closeEffect: 'elastic'
            });
          }, 3000);
        }
      });
        });
        return false;
    });

fancybox i use 3 versions of fancyapps.com/fancybox/3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Lysenko, 2017-05-31
@mrusklon

$.fancybox.open({
  src  : '#hidden-content',
  type : 'inline',
  opts : {
    onComplete : function() {
      console.info('done!');
    }
  }
});

Documentation

T
ThunderCat, 2017-05-31
@ThunderCat

here it is recommended to stupidly trigger a click event on the desired element

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question