嗨,我正在使用php执行python脚本,但我不希望在单击按钮时刷新页面,因为我也嵌入了其他页面


Hi , i am executing a python script using php but I do not want the page to refresh when a button is clicked because i have embedded other pages too

这是php和html代码我正在使用运动流视频在它

<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<?php
if (isset($_POST['LightBLINK']))
{
exec("sudo python /var/www/html/open.py");
}
?>
<form method="post">
<button class="btn" name="LightBLINK">Light BLINK</button><br><br></form> 
<body>
<h1>Raspberry Pi Webcameras</h1>
<a href="http://192.168.1.3:8081/">
<img src="http://192.168.1.3:8081/" alt="Camera 1" ></a>
<a href="http://192.168.1.3:8082/">
<img src="http://192.168.1.3:8082/" alt="Camera 2" ></a>
</body>
</html>

问题是,当我单击"LIGH BLINK"按钮时,它会执行open.py脚本,但同时会刷新整个网页,这会导致嵌入的页面(在我的情况下是视频)刷新。

我想要的是,当我点击"LIGHT BLINK"按钮时,它应该像以前一样执行open.py脚本。但不要刷新整个页面,这样我的视频源就不会受到干扰。

使用JQUERY Ajax

    $.post("url to process data",{data:data}, function(response){
       //do something with the response
     )};