.js file can't take more than 1 refresh call?
Design and Skin Customization
I have a JS function to periodically update a div. It gets called once in the footer template and then runs all the time the page is open. It uses an ajax call to get the data, and it only updates the div if the returned data is different from the previous returned data.
function jrSocialModuleAlerts(timeout) {
var _html = new Array('','');
var url = core_system_url + '/socialmodule/alerts/__ajax=1';
timeout = timeout * 1000;
setInterval(function() {
$.ajax({
type:'POST',
url: url,
data:{},
dataType:'json',
success:function (data) {
if (data.OK == 1) {
// Update profile alerts
if (typeof data.alerts !== "undefined") {
_html[0] = data.alerts;
if (_html[0] != _html[1]) {
$("#alerts").fadeOut("slow").html("");
var interval = setInterval(function() {}, 500);
$("#alerts").fadeIn("slow").html(data.alerts);
_html[1] = data.alerts;
}
}
else {
$("#alerts").fadeOut("slow").html("None found");
}
}
else {
$("#alerts").html(data.error);
}
},
error:function () {
$("#alerts").html('an error was encountered - please try again');
}
});
}, timeout);
}
Pa