PHP / AJAX函数刷新


PHP / AJAX function refresh

我的函数有问题。我想刷新这个函数每5秒不刷新页面!

这是在刷新。php:

if ($files_count == 0) {         
        ?>       
    <img src="img/upload.gif">                 
    <?php    
   }

,这是在index.php:

<?php include 'refresh.php'; ?>

怎么做?: D

编辑:

HTML

<div class="container"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
JavaScript

setInterval(function(){check_files();}, 5000);
function check_files() {
   $.ajax({
      url: 'path/to/php/file.php',
      type: 'GET',
      cache: false,
      data: {},
      success: function (resp) {
         if (resp == 0) {
            $('.container').html('<img src="img/upload.gif" />');
         }
         else {
            /// Something else
         }
      }
   });
}
PHP

<?php
$count = count(glob("your_directory/*",GLOB_BRACE)); // This is what I assume you're counting files with. You may be counting from a database, though. 
echo $count; // This goes back to the AJAX call.