Php 使用Ajax更新网页的自定义触发器

Php 使用Ajax更新网页的自定义触发器,php,jquery,ajax,Php,Jquery,Ajax,举个例子,让我们使用以下psuedo代码: $animals = getAnimals(); // getAnimals() gets data from a MySQL table and returns the result as an array for($i=0; $i<count($animals);$i++) { echo "<tr><td>".$animals[$i][0]."</td><td>".$animals[$i][

举个例子,让我们使用以下psuedo代码:

$animals = getAnimals(); // getAnimals() gets data from a MySQL table and returns the result as an array
for($i=0; $i<count($animals);$i++) {
  echo "<tr><td>".$animals[$i][0]."</td><td>".$animals[$i][1]."</td></tr>";
$animals=getAnimals();//getAnimals()从MySQL表获取数据,并将结果作为数组返回

对于($i=0;$i您可以使用
setInterval

setInterval(function(){ 
   $.post('ajax.php', {data: 'x'}, function(reponse) {
      //Do what you want with response 
   });
}, 30000);

有一些解释。

您可以使用
setInterval

setInterval(function(){ 
   $.post('ajax.php', {data: 'x'}, function(reponse) {
      //Do what you want with response 
   });
}, 30000);

有一些解释。

谢谢,先生,你是明星!谢谢,先生,你是明星!
setInterval(function(){ 
   $.post('ajax.php', {data: 'x'}, function(reponse) {
      //Do what you want with response 
   });
}, 30000);