如果我等待没有点击页面上的任何内容,.click jquery不起作用

The weirdest thing. If I upload my files and start clicking on the link it works just fine. However if I go surf on another tab and then come back to it and click the link the .post or .click jquery doesn't seem to work. I only included excerpts of the code. Let me know if you need to see more code. Thanks!!

likeOnClick.php file

       <script type="text/javascript"  src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
        <script type="text/javascript" src="includes/js/jquery.form.js"></script>
        <script type="text/javascript">

      $(document).ready(function() {
  $(".like").click(function() {
  var data = $(this).attr('data-id');
   $.post("updateLikes.php", {'id': data});
   });
return false;
 });
 </script>

...

displayDBUsers.php

            while($row = mysql_fetch_array($result))
     {
    ?>
    <?php $id = $row['uniqueid'];?>
    <?php $finalID = "showdata" . $id ;?>
    <?php echo "<br>FinalID: " . $finalID;?>
    <?php echo "<br>ID: " . $row['uniqueid'];?> 
    <?php echo "<br>Name: " . $row['surname']; ?>
    <?php echo "<br><a href class=like data-id=" . $id . ">Like (" . $row['likes'] . ")</a>"; ?>
    <?php echo "<br><br>"; ?>
<?php
}

...

updateLike.php

  if( $_POST['id'])
  {
$unique_id = mysql_real_escape_string($_POST['id']);
$sql = "
UPDATE atable
 SET likes=likes + 1
 WHERE uniqueid=$unique_id;";

$result = mysql_query($sql);
if(!$result)
{
    echo "Failed to retrieve record";
}

Please pay attention. return false; placed in different position:

<script type="text/javascript">
    $(document).ready(function() {
        $(".like").click(function() {
            var data = $(this).attr('data-id');
            $.post("updateLikes.php", {'id': data});
            return false;
        });
    });
</script>

Put quotes around your attribute values:

  echo "<br><a href=\"\" class=\"like\" data-id=\"1\">Like</a>";