单击保存后如何刷新php页面?

时间:2018-01-20 12:48:47

标签: javascript php ajax refresh page-refresh

我有一个要编辑的页面表单,使用提交按钮' save'。单击保存后,我希望我的页面自动刷新以显示修改。但我希望它只有在我延迟后不点击保存时才刷新。只需一次,无需每隔x秒刷新一次!

if (isset($_POST['ajout'])) {
        $travail = str_replace("'","&#039", $_POST['travail']);
        $req = $fun -> modifier($_POST['name'], $travail);
        if ($req) {
            echo '
                <script type="text/javascript">
                    setTimeout(function() {
                        document.getElementById("merci").style.display = "none";
                    },10000);
                </script>
                <div id="merci" class="alert alert-success fade in">
                    <button data-dismiss="alert" class="close close-sm" type="button">
                        <i class="fa fa-times"></i>
                    </button>
                    success
                </div>
            ';
        } else {
            echo '
                <script type="text/javascript">
                    setTimeout(function() {
                        document.getElementById("merci").style.display = "none";
                    },10000);
                </script>
                <div id="merci" class="alert alert-danger fade in">
                    <button data-dismiss="alert" class="close close-sm" type="button">
                        <i class="fa fa-times"></i>
                    </button>
                    <strong>erro</strong> try aagain
                </div>
            ';
        }
}

0 个答案:

没有答案