2

I have a notification system that works with the following codes

jQuery:

$(document).ready(function(){$.get('/codes/php/nf.php', function(data) {
$('#check').html(data);});
});
setInterval(function(){$.get('/codes/php/nf.php', function(data) {
$('#check').html(data);});
}, 10000);

PHP:

   //Database stuff would be here
    $na = $num_rows; //Amount of notifications
    if($na == "1"){
    $nt="Notification";
    } else {
    $nt="Notifications";
    }
    if($na != "0"){
    echo "<a href='#'>$na $nt</a>";
    } else {
    exit;
    }

HTML: (It's a tipsy -- jQuery plugin -- tooltip)

title="<span id='check'>"

My only problem is when there is 0 notifications ($na = 0) a blank tooltip is displayed, and it looks really bad. So basically I can't have the 'title=' if I want to get rid of this problem, but I don't have any ideas. Anybody know I can fix this?

Ok, so I found out that I can't use this: title="" at all because even when there is no data at all, the tooltip is still being displayed.

2
  • Show us the element that the title attribute is on. Commented Dec 16, 2011 at 4:07
  • <img src="/images/logo.png" id="headimg" title="<span id='check'>"> Commented Dec 16, 2011 at 4:47

1 Answer 1

2

try change

function(data) {
   $('#check').html(data);
}

with this :

function(data) {
   if (data != '') { 
      $('#check').html(data);
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.