Getting UnreadmessagesCount
<p>The question I have here is for some reason when the getInboxUnreadMessagesCount js function is ran then it comes up with a different number then what is there to begin with and keep in mind there is no new message being sent. When I run the php dashboard functions they both are returning the correct numbers but I think the issue lies with the last line of code with the messageTimer</p>

<p>Anybody even have any thoughts onto what it might be? I'm hoping someone can figure it out.</p>

<pre><code>var $messageCountJSON;
var messageTimer = '';
var messageInterval = 5;

//assumed JSON response is {"count":"20"} for example sake.

function getInboxUnreadMessagesCount(displayElementID) {
    $.get('dashboard/getInboxUnreadMessagesCount', function (data) {
        $messageCountJSON = data;
    }, 'json');
    if (displayElementID != null &amp;&amp; displayElementID != undefined &amp;&amp; displayElementID != '') {
        //$('#'+displayElementID).html($messageCountJSON);
        if (parseInt($('#' + displayElementID).text()) &lt; parseInt($messageCountJSON)) {
            $.jGrowl("You have received a new private message!", { theme: 'information' });
            $('#' + displayElementID).html($messageCountJSON).css({ "display": "block" });
        }
        if (parseInt($messageCountJSON) == 0) {
            $('#' + displayElementID).html($messageCountJSON).css({ "display": "none" });
        }
    }
}

function getInboxMessagesCount(displayElementID) {
    $.get('dashboard/getInboxMessagesCount', function (data) {
        $messageCountJSON = data;
    }, 'json');
    if (displayElementID != null &amp;&amp; displayElementID != undefined &amp;&amp; displayElementID != '') {
        //$('#'+displayElementID).html($messageCountJSON);
        if (parseInt($('#' + displayElementID).text()) &lt; parseInt($messageCountJSON)) {
            $('#' + displayElementID).html($messageCountJSON);
        }
        if (parseInt($messageCountJSON) == 0) {
            $('#' + displayElementID).html($messageCountJSON);
        }
    }
}
$(document).ready(function () {
    messageTimer = setInterval(function () { getInboxUnreadMessagesCount('notifications'); getInboxMessagesCount('inboxCount'); }, messageInterval * 1000);
});

//you can optionally kill the timed interval with something like
//$('#pmMessagesIcon').click(function(){clearInterval(messageTimer);})
</code></pre>
