I am currently working on a Periodical Updater using prototype js, and my goal is to hide every element on the page with the class='robot'
based on the response received from an AJAX request. If the response matches hidethemall
, I want all elements with class='robot'
to be hidden. Otherwise, no action should be taken.
Up to this point, I have managed to reset my function after a certain number of periodic updates in order to reduce server load. Here is how my function looks:
function updatePeriodically(span_id, processing_url, parameters,
frequency, decay, reset_decay_time)
{
var ajax = new Ajax.PeriodicalUpdater({success: span_id}, processing_url,
{
method:'get',
frequency: frequency,
decay: decay,
parameters: parameters,
evalScripts: true,
onSuccess: function(response) { //or onComplete
if (ajax.decay >= reset_decay_time)
{
ajax.decay = decay;
}
}
});
}
updatePeriodically('new_message_count',
'refresh_unread_messages.php', '&user=currentuser', 10, 2, 1800);
Questions
How can I modify this to prevent updating the div and instead hide every div with the class class='robot'
when the AJAX response equals hidethemall
?