title: Facing on Make Like Unlike Button in php , mysql using ajax calling
body: <p>I m creating like and unlike button for my website , at my local server i used seprate file it it working fine but when i install at my website then it is not working properly.</p>
  
  <p>I m Fetching some information using this code from url bar</p>
  
  <pre><code>    &lt;?php
      error_reporting (0);
      include "includes/session.php";
  
      include 'database/db.php';
  
      extract($_REQUEST);             
      if(isset($_GET["i"]))
      {
      $pid=($_GET['p']);
      $lid=($_GET['i']);
      }
      ?&gt;
  
      &lt;?php
      $likquery = mysql_query("select * from likes where userid=$id and postid=$lid");
      if(mysql_num_rows($likquery)==1){
  
      ?&gt;
          &lt;a class="unlike" id="&lt;?php echo $lid ?&gt;"&gt;UnLike&lt;/a&gt;&amp;nbsp;&lt;span class="like_update" id="&lt;?php echo $lid ?&gt;"&gt;&lt;/span&gt;
  
      &lt;?php }else{?&gt;
  
          &lt;a class="like" id="&lt;?php echo $lid ?&gt;"&gt;Like&lt;/a&gt;
  
  
  
          &lt;?php 
      }?&gt;
  </code></pre>
  
  <p>AFTER this I use script</p>
  
  <pre><code>    &lt;script src="js/jquery-1.8.3.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script&gt;
      $(document).ready(function(){
  
      $('body').on('click','.like',function(){
  
  
      var postId = $(this).attr('id');
  
      var postData = 'postid='+postId+'&amp;uid=&lt;?php echo $id ?&gt;';
  
      $.ajax({
  
          type: "POST",
          url: "like_notes",
          data: postData,
          cache: false,
          success: function(){
  
              $('#'+postId).text('UnLike').addClass('unlike').removeClass('like');
          }
  
      });
  
      })
  
  
  
      $('body').on('click','.unlike',function(){
  
      var postId = $(this).attr('id');
  
      var postData = 'postid='+postId+'&amp;uid=&lt;?php echo $id ?&gt;';
  
      $.ajax({
  
          type: "POST",
          url: "likeun_notes",
          data: postData,
          cache: false,
          success: function(){
  
              $('#'+postId).text('Like').addClass('like').removeClass('unlike');
          }
  
      });
  
      })
  
      });
  
      &lt;/script&gt;
  </code></pre>
  
  <p>And I m not getting any response but when i use</p>
  
  <pre><code>&lt;script src="js/jquery-1.8.3.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
  
  $(".like").click(function(){
  
      var postId = $(this).attr('id');
  
      var postData = 'postid='+postId+'&amp;uid=&lt;?php echo $id ?&gt;';
  
      $.ajax({
  
          type: "POST",
          url: "like_notes",
          data: postData,
          cache: false,
          success: function(){
  
              $('#'+postId).text('UnLike').addClass('unlike').removeClass('like');
          }
  
      });
  
  })
  
  
  $(".unlike").click(function(){
  
      var postId = $(this).attr('id');
  
      var postData = 'postid='+postId+'&amp;uid=&lt;?php echo $id ?&gt;';
  
      $.ajax({
  
          type: "POST",
          url: "likeun_notes",
          data: postData,
          cache: false,
          success: function(){
  
              $('#'+postId).text('Like').addClass('like').removeClass('unlike');
          }
  
      });
  
  })
  
  });
  
  &lt;/script&gt;
  
  only once it is changing the value 
  </code></pre>