Monday, January 31, 2011

Auto Refresh a Div or an Element using Jquery

Below is the code to refresh a div or an element using Jquery.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Refresh</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function()
{
$('#replace_content').load('
replace_content.php');
}, 1000);
</script>
<style type="text/css">
#shouts { background: #36F; height: 200px; overflow: auto; width: 300px; }
</style>
</head>

<body>
<div id="replace_content"><?php include'replace_content.php'?></div>
</body>
</html>



  



2 comments:

dskanth said...
This comment has been removed by the author.
dskanth said...

Good one... we can output time or date with the php file dynamically for refreshing every second and showing latest time.