如果条件,在PHP内部调用jQuery函数

问题描述 投票:-1回答:1

如果PHP条件为真,我需要调用jQuery函数,但不知何故我找不到合适的解决方案:

这是我的php / html代码:

<?php if(isset($_GET['success'])) { ?>
    <div class="alert alert-success">
        <script>//Here I want to call a showNotification function</script>
    </div>
<?php } ?>

这是我在js代码中的函数:

showNotification: function(from, align) {
    color = Math.floor((Math.random() * 4) + 1);
    $.notify({
        icon: "pe-7s-gift",
        message: "<b>Light Bootstrap Dashboard PRO</b> - forget about boring dashboards."
    },{
        type: type[color],
        timer: 4000,
        placement: {
            from: from,
            align: align
        }
    });
}
javascript jquery
1个回答
0
投票

Javascript是一种客户端语言(在您的域中),PHP是服务器端语言。如果满足服务器端的条件,则只能在服务器响应中包含脚本标记。

© www.soinside.com 2019 - 2024. All rights reserved.