Thanks for your reply sanford.
I have got a script which works on click method. I have tried to
modify it to make it auto refresh instead of on click refresh.
here is the code-
<script type="text/javascript" src="js/mootools.js"></script>
<script type="text/javascript">
window.addEvent("domready", function()
{
$('loadOnce').set('load', {'method' : 'get' } );
// the shortest way to get something could be also a complex
Request.JSON or so
$('loadOnce').load(window.demo_path + 'test.php');
/*
---------------------------------------------------------------------------------------------------
periodical refresh every 4 seconds
---------------------------------------------------------------------------------------------------
*/
// for peridiodical request its a good idea to set autoCancel to
true
$('loadPeriodical').set('load', {'autoCancel' : 'true', 'method' :
'get' } );
function refresh() {
noCache = '?a=' + $time() + $random(0, 100);
$('loadPeriodical').load(window.demo_path + 'test.php' +
noCache);
}
refresh.periodical(4000);
//needs to be called once, or you will have to wait 4 seconds for
the first time
refresh();
var timer;
$('loadPeriodicalControlls').set('load', {'autoCancel' : 'true',
'method' : 'get' } );
function refreshControlls() {
noCache = '?a=' + $time() + $random(0, 100);
$('loadPeriodicalControlls').load(window.demo_path +
'test.php' + noCache);
}
$('startButton').(function(){
//get the rate form the input or use default of 4 seconds if
there is no value [no validation to keep it simple]
rate = $('periode').value || 4;
$clear(timer);
timer = refreshControlls.periodical(rate*1000);
refreshControlls();
//just to mark the periodical action
$('loadPeriodicalControlls').addClass('periodical');
});
});
</script>
<body>
<h1>periodical request</h1>
<h2>load once on startup</h2>
<div id="loadOnce" class="box"></div>
<h2>load periodical every 4 seconds</h2>
<div id="loadPeriodical" class="box periodical"></div>
<h2>load periodical with controlls</h2>
<div id="loadPeriodicalControlls" class="box"> use the start button
</div>
<div id="startButton">start</div>
I am getting an error the following error-
Error: $("loadOnce").load is not a function
Source File:
Line: 11
Can anyone please tell my why i am grtting this error?
On Feb 9, 10:59 pm, Sanford Whiteman <[email protected]>
wrote:
> > noCache = '?a=' + $time() + $random(0, 100);
>
> P.S. Not feeling cache invalidation. If I am reloading a giant DIV
> every second, best believe I want to get a 304 whenever possible.
> There will be some old browsers (yeah, IE6) where you may need brute
> force to force a refresh from the server, but otherwise you should
> rely on wise use of HTTP caching headers (client + server), not
> invalidate on every call.
>
> -- S.