title: Jquery Ajax Buttons
body: <p>Could somebody please tell me why my like button is not working? I attached a like button on my blog and used Ajax to send each like counter to be stored in a mySQL database. But, apparently it is not working. Here are my JQuery functions:</p>
  
  <p>            
       </p>
  
  <pre><code>$(document).ready(fuction() {
  
  
      function likefunction(catch_blog_id) {
  
      var count = 1;
      var catch_id = catch_blog_id;
      var status = $('#likelink').html(); 
      var vardata = 'count' + count + '&amp;catch_id' + catch_id;
  
  
      if (status == "Like") {
      $.ajax({  
  
          type: "POST",
          url: 'like.php',
          data: vardata,
          success: function() {$('#likelink').html("Unlike");}
  
      })
  
      } else {
  
      $.ajax({  
  
          type: "POST",
          url: 'unlike.php',
          data: vardata,
          success: function() {$('#likelink').html("Like");}
  
      })
      }
      }
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>here is the .php files: one for the like function and the other for the unlike function ==</p>
  
  <pre><code>like: 
  
  &lt;?php
  
  include_once('connectserver.php');
  
  $catch_blog_id = $_POST['catch_id'];
  $catch_count = $_POST['count'];
  
  
  $query_blog = mysql_query("SELECT `likes` FROM `posts` WHERE `id` = '$catch_blog_id'");
  
  while($get_rows = mysql_fetch_assoc($query_blog)) {
  
  
   $likes = $get_rows['likes'];
   $likes = (int)$likes;
   $likes++;
  
   mysql_query("UPDATE `posts` SET `likes` = '$likes' WHERE `id` = '$catch_blog_id'");
  
   }
  
  
  
  
  
  
  
     ?&gt;
  
  
     unlike: 
  
  
  
     &lt;?php
  
       include_once('connectserver.php');
  
      $catch_blog_id = $_POST['catch_id'];
         $catch_count = $_POST['count'];
  
  
        $query_blog = mysql_query("SELECT `likes` FROM `posts` WHERE `id` = '$catch_blog_id'");
  
       while($get_rows = mysql_fetch_assoc($query_blog)) {
  
  
       $likes = $get_rows['likes'];
     $likes = (int)$likes;
      $likes--;
  
         mysql_query("UPDATE `posts` SET `likes` = '$likes' WHERE `id` = '$catch_blog_id'");
  
          }
  
  
  
  
  
  
  
      ?&gt;
  </code></pre>
  
  <p>here is part of the html file used to store the like button:</p>
  
  <p>echo "<br>Like Comment";</p>