提交后刷新整个页面(Fancybox)


Refresh the whole page after submit (Fancybox)

我有一个页面,用户将在其中单击按钮,然后会出现一个fancybox弹出窗口,其中有一个php文件,其中包含您可以更新的所有字段。我想发生的是,在我按下更新按钮后,整个页面将刷新并关闭弹出窗口。但实际情况是,在我按下更新后,只有弹出窗口会刷新。我怎么能那样做?

在这个页面中,我回显所有的用户信息

emp_refer.php

       <a id="various5" href="http://i-refer.elitebpocareers.com/refer/updateInfo.php">
                    <button class="button">Edit Personal Information</button>
                </a>

        <SCRIPT TYPE = "text/javascript">
        $("#various5").fancybox({
         'width'             : '75%',
         'height'            : '75%',
         'autoScale'         : false,
         'transitionIn'      : 'none',
         'transitionOut'     : 'none',
         'type'              : 'iframe'
        });
        </SCRIPT>

然后在更新后的第2页中,我做了这个代码,弹出窗口只刷新

echo "<meta http-equiv='refresh' content='0; url=emp_refer.php'>";

您可以做的是:

在第2页中,更新后运行fancybox.close()方法,而不是meta标签,如:

echo "<script>parent.jQuery.fancybox.close();</script>";

然后,在fancybox初始化脚本(emp_refer.php页面)中,将onClosed回调添加到API选项中,并在其中运行location.reload(),如:

$("#various5").fancybox({
    'width': '75%',
    'height': '75%',
    'autoScale': false,
    'transitionIn': 'none',
    'transitionOut': 'none',
    'type': 'iframe',
    'onClosed': function () {
        location.reload();
        return;
    }
});

注意:如果您使用的是fancybox v2.x,请使用afterClose回调