如何在php-ajax调用验证成功后关闭javascript弹出框

How do I close javascript popup box after validation is successful with php ajax call

本文关键字:javascript 成功 php-ajax 调用 验证      更新时间:2023-09-26

在我的html表单中,会出现一个用于注册的弹出窗口。它使用带有regProcess.php页面的ajax/查询调用来验证数据。此页面正在使用json_encode将数据传递到html表单。好吧,当所有验证都成功时,我想在几秒钟后关闭html弹出框。我该怎么做?

<script>
  $('#form1').submit(function(event) {
    event.preventDefault();
    $.ajax({
      type: 'POST',
      url: 'backup.php',
      data: $(this).serialize(),
      dataType: 'json',       
      success: function (data) {
        $('#info1').html('');
        $.each( data, function( key, value ) {
          $('#info1').append('<p>'+value+'</p>');               
        });    
      }
    });
  });
</script>

弹出窗口显示以下div调用。

<div id="register">
  <a class="big-link" data-reveal-id="myModal">
    <button type="button" name="" value="" class="css3button">Join the campaign</button>
  </a>
</div>

您可以使用setTimeout()将jquery函数放入成功函数

http://www.w3schools.com/jsref/met_win_settimeout.asp