I corrected my post above, the Prototype function is Ajax.PeriodicalUpdater() which takes a refresh delay and a decay value (decay is a multiplier for delay whenever the returned value is the same as last time).
I'm not finding anything too useful for jquery as I'm not so familiar with it. googling "jquery periodicalupdater" returned a link to here:
http://www.jasons-toolbox.com/JHeartbeat/ but that doesn't take a decay argument (like suggested in the OP).
Maybe a modification of something like:
http://www.aspcode.net/Timed-Ajax-calls ... SPNET.aspx to be closer to this:
- Code: Select all
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
var delay = 3; // start with a 3 second interval
var decay = 2; // everytime we query the same info, increase the decay by 2 fold
var c_delay = 1; // doesn't really matter, just setting to 1 incase i screwed something up
var previous = null; // previous return data
$(document).ready(function() {
setTimeout(MyUpdate,delay * 1000);
});
function MyUpdate()
{
$.get("ajaxdata.ashx",function(result) {
var new_delay =
if (result == previous) {
// same data as last time, do nothing but increase our delay
c_delay = delay * decay;
} else {
// {do work with result}
previous = result;
// reset delay
c_delay = delay;
}
});
setTimeout(MyUpdate,c_delay * 1000);
}
That should do about the same as PeriodicalUpdater I think, I haven't tested it; but, feel free to play around with it!
Enjoy