我有一个关于如何使用if else语句调用php脚本中的javascript函数的问题
这是我的PHP代码
if (!$output) {
!! here i want to call a javascript function !!
// $status = "Server has been shutdown!";
// $date = date('Y-m-d H:i:s');
$serverDate = time();
$serverStatus = 0;
} else {
这里是我要调用的javascript我只是想让你们知道我添加了函数OfflineStatus(){}; idk如果能调用VAR变量?
function OfflineStatus() {
var nodes = [
{ hostname: "", status: "OFFLINE", address: "", icon: "tasks" },
{ hostname: "", status: "OFFLINE", address: "", icon: "tasks" }
];
}
原始代码是这个
var nodes = [
{ hostname: ", status: "OFFLINE", address: "", icon: "tasks" },
{ hostname: "", status: "OFFLINE", address: "", icon: "tasks" }
];
答案 0 :(得分:0)
您可以使用php在<script></script>
<script>
<?php
if (!$output) {
echo "OfflineStatus();";
}
?>
</script>