Search code examples
javascriptprototypejs

Prototype JS Framework - Calling a function when updates occur with a periodic updater


How do I call a function on every update? Below is what I tried. It doesn't work. The function itself works fine when I execute it alone.

new Ajax.PeriodicalUpdater('chatMessages', 'chat/receive_chat',
        {
                method: 'post',
                parameters: {lId: latestId},
                insertion: Insertion.Bottom,
                frequency: 2,
                decay: 2,
                Onsuccess: val = function(){$('chatMessages').scrollTop = $('chatMessages').scrollHeight;}
        });

Solution

  • Is this as simple as a case-sensitivity issue?

    You have:

    Onsuccess: function(){...}
    

    Should it be:

    onSuccess: function(){...}