PHP/Javascript: Making (1) in title as unread
<pre><code>$counter = $sWall + $sWC + $sOther;
if (!empty($counter)) {
    echo '(' . $counter . ')';
    $counter = 0;
}
</code></pre>

<p>And js:</p>

<pre><code>    $(window).blur(function() {
        tracktime = new Date();
         setInterval(function() { 
      $.ajax({ 
       type: "POST",
       url: "imback.php",
    data: {
    mode: 'ajax',
            getUpdates: 'auto',
            },
       success: function(msg){
       document.title = msg + document.title;
    }
     });
}, 2000);

    })
</code></pre>

<p>For showing new unread comments in the title bar. Works fine and displays it as (1), although everytime it call, it adds a (1) so the title gets like this: (1)(1)(1)(1)(1)(1)(1)(1).......</p>

<p>And i only want it to do it once (1) no matter how many calls, so if a new call is response is (2) then it will show (2) and not (2)(1)(1)....</p>

<p>How can i fix this the best way?</p>
