[英]Call jQuery function inside PHP if condition
如果 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 是一種客戶端語言(在您的域中),而 PHP 是一種服務器端語言。 如果您在服務器端的條件得到滿足,您只能在服務器響應中包含腳本標記。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.