0

我想通过 PHP触发Alertify警报。现在,当单击按钮时会出现警报,但我想在 PHP 插入查询成功时显示警报。

我的代码如下:

<script type="text/javascript">
    $(function() {
        $('.run').click(function(event){
            alertify.alert('Housing successfully updated.').show();
        });
    });

</script>

<button class="run">Show alert</button>
4

1 回答 1

0

尝试这个:

//query<br/>
$insert = your query;<br/>
                if($insert){<br/>
                    $_SESSION['modal'] = "success";<br/>
                    header('location: redirect');<br/>
                }else{<br/>
                    $_SESSION['modal'] = "failed";<br/>
                    header('location: redirect');<br/>
                }<br/>

//load the session and show alert <br/>
    if(isset($_SESSION['modal'])){<br/>
        $modal = $_SESSION['modal'];<br/>
        <script>//your alert script</script>

    }<br/>
    unset($_SESSION["modal"]);<br/>
?><br/>
于 2016-10-26T23:38:11.837 回答