Refresh a div at every 10 seconds

Some cases we need to refresh a part of a web page in a specific interval of time. For e.g., Cricket score board, share market updates, online users etc.. In these places we need to refresh a part of web page without reloading the whole page.

Refresh a div at every 10 seconds
Click image to view LargerBy using Jquery, Ajax and PHP we can refresh a div and make that area of web page up to date. So that your web page will become more user friendly and more attractive.

Below I will explain how to do that. If you want you can view demo and download the example file below.

Demo Download

Create a HTML and Jquery Ajax call back page like below

   var j = jQuery.noConflict();
			  url: "refresh-me.php",
			  cache: false,
			  success: function(html){
This will get Refreshed in 10 Seconds

Now you should include two Jquery file to sprinkler the Ajax at set time

<script language="javascript" src="js/jquery-1.2.6.min.js"></script>
<script language="javascript" src="js/jquery.timer-1.0.0.js"></script>

Below is the PHP to get current time. (In this case)

echo date('g:i s a');

Now upload file and run the script. For every 10 seconds the div will get refreshed and show the current time using PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>