html - How to use JQuery to auto reload div content every X seconds? -
i have been doing web page, , encountered problem on reloading div content.
i have done research, , of examples found on has "script.php" on .load(), not need... (example)
is there way use .load() load specific div content again?
(btw, sry bad english etc... , hope explanation makes sense)
code:
<head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> function update(){ $('#div1').load("index.html #div1"); } setinterval( 'update()', 1000 ); </script> </head>
<body> <div id="div1"> <script language="javascript"> <!-- date=date() document.write(date) //--> </script> </div> </body>
if requirement call function interval of time. use :
function update() $('#div1').load("index.php"); //$('#div1').load("index.jsp"); }); $(function() { update(); //to run on page load setinterval(update,1000); }
use server side code date below:
php:
<h1><?= date("y/m/d h:m:s") ?></h1>
jsp:
<h1> <% date date = new date(); simpledateformat ft = new simpledateformat ("yyyy/mm/dd hh:mm:ss"); out.print(ft.format(date)); %> </h1>
Comments
Post a Comment