我有这个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