Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图在 php 页面处于活动状态时每 30 秒在服务器上本地保存一个实时摄像头图像。
我目前正在使用下面的代码,它可以很好地在页面加载时引入当前的实时图像:
exec('php -q /path/to/file/saveimage.php');
我遇到的问题是让上述代码每 30 秒运行一次。我用 ajax/jQuery 尝试了一些不同的尝试,但无法让它们工作。
似乎它应该很简单,因为它需要做的就是执行.php,但我似乎无法弄清楚。
正如蒂姆所说:
<script> setInterval(function(){ $.get('/path/to/file/saveimage.php'); }, 30000); </script>