来自文本文件的AJAX请求

So I've created this rating system with a rating of stars(img) that you click on, 1-5. Right below it I have added an average counter. This is AJAX so whenever you rate, it will send a call to the text file and update the average number without reloading the page. Yeh yeh, you know the deal.

But what I need help with is to display this statistics all the time. Right now the average count information only appear after you've clicked the rating.

Code:

<script>
$(document).ready(function(){
    $('div#rating-area img').click(function(){
        $('#target').load('ajax.php');
    });
});
</script>

<div id="target">&nbsp;</div>

I tried by changing the click function to onload function. But it did not work.

use an interval , and calls the file to update the values ​​every second (for example)

<script>
   $(document).ready(function(){

       setInterval(function(){

              $('#target').load('ajax.php');

       },1000);

   });
 </script>

I disagree with the accepted answer to use an interval for this purpose, all you need to do is to call LoadRatings() after page load and after clicking the rate image

<script>
   function LoadRatings() {
     $('#target').load('ajax.php');
   }

   $(document).ready(function(){   
     LoadRatings(); 
     $('div#rating-area img').click(loadRatings);   
   });
 </script>