在PHP插入查询上触发Alertify警报

时间:2016-10-26 23:03:58

标签: javascript php html mysql alertify

我想通过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>

1 个答案:

答案 0 :(得分: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/>