我有這個variable.php其中包含一個變量:刷新變量
<?php
// Start the session
session_start();
?>
<html>
<head>
<link rel="stylesheet" href="style.css"/>
<body>
<div>
<?php
$output = shell_exec("sh r.sh");
$op = preg_split("#[\r\n]+#",trim($output));
$rest = substr("$op[0]",-5);
$value= hexdec($rest);
$value=$value/1000;
?>
<?php
$_SESSION["value1"] = "$value";
?>
</div>
</body>
</head>
</html>
和我有這個index.php頁面,其顯示我的變量值:
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" href="style.css"/>
<body>
<?php print $_SESSION["value1"] ; ?>
</body>
</head>
</html>
我怎樣才能使用Jquery從variable.php中刷新變量$ value並在index.php中每1秒刷新一次?
我嘗試這樣做:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
setTimeout("location.reload(true)",1000);
</script>
但它只是刷新的index.php,但不是variable.php
感謝。
你好,歡迎來到Stackoverflow。我們在這裏幫助您解決特定的編程問題,而不是爲您編寫代碼。告訴我們你試過的東西,與我們分享你的想法,我們會提供幫助,但沒有人會爲你寫代碼。首先,你的變量.php中不需要所有'html'標籤,你不會顯示任何內容。 – Twinfriends
我試圖這樣: 但它刷新index.php每1秒,但不是變量。 – Zekeriya