我正在使用樹莓派脈衝繼電器(在下面的表單提交)到另一臺設備,如果成功脈衝將打開/關閉一個繼電器。切換的繼電器返回到pi,作爲在加載div內的status.php頁面上監視的輸入。如果我加載下面的頁面,它會正確顯示status.php,但是在按下表單提交按鈕後,它不會重新加載status.php頁面。我嘗試了所有我能想到的,請幫助!PHP/Javascript/Python不能重新加載div
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Alarm Panel</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
$.ajaxSetup({ cache: false });
setInterval(function() {
$('#loading').load('/status.php');
}, 2000);
});
// ]]>
</script>
<?php
if (isset($_POST['PULSE'])) {
shell_exec('python /usr/lib/cgi-bin/pulse.py');
}
?>
</head>
<body>
<div id="currentstatus" data-role="collapsible" data-theme="b" data-content-theme="b" data-collapsed="false">
<h1>Current status</h1>
<div id="loading" align="center">
<H3>Loading Status...</H3>
</div>
</div>
<div data-role="collapsible" data-theme="b" data-content-theme="b">
<h4>Change Status</h4>
<form method="post">
<input type="submit" name="PULSE" value="PULSE" />
</form>
</div>
</body>
</html>
status.php <?php $status = shell_exec('python /usr/lib/cgi-bin/status.py'); ?> <h3><? echo $status; ?></h3> <br /> <img src="/img/<? print $status; ?>.jpg" height="250"; width="250";>
你試圖設置窗體的'行動= '?''?這似乎是表格不提交給它的父文件... – Todd
大聲笑。實際上,我認爲這可能是無關緊要的。讓我嘗試一個真正的解決方案... – Todd
什麼是status.php? – OIS