title: Getting an error with ajax-request
body: <p>I want to make a like/dislike ability on my web application but I get errors here:</p>
  
  <p>1) Like/dislike increments by 2 per ONE click
  2) The request is sent, it updates the like/dislike variable, but I have to reload the page to see the new updated data.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>Here's my code:</strong></p>
  
  <p><strong>My view:</strong></p>
  
  <pre><code>#app/views/dashboard/view.html.erb 
  &lt;td&gt;&lt;span class="glyphicon glyphicon-thumbs-up likeAction"&gt;&lt;%=  p.like %&gt; &lt;/td&gt;
  &lt;td&gt;&lt;span class="glyphicon glyphicon-thumbs-down dislikeAction"&gt;&lt;%= p.dislike %&gt; &lt;/td&gt;
  </code></pre>
  
  <p><strong>My controller:</strong></p>
  
  <pre><code>#app/controllers/dashboard_controller.rb 
    def like
      @post=Post.find(params[:id])
      @post.increment!(:like)
    end
  
    def dislike
      @post=Post.find(params[:id])
      @post.increment!(:dislike)
    end
  </code></pre>
  
  <p><strong>My JS file:</strong></p>
  
  <pre><code>jQuery(function($) {
    $(".likeAction").click(function(){
      var current_post_tr = $(this).parents('tr')[0];
      $.ajax({
        url: 'http://localhost:3000/dashboard/' + $(current_post_tr).attr('data-post_id') +'/like',
          type: 'PUT',
          success: function(){
            $("#likeAction").hide().fadeIn();
          }
       });
    });
  
    $(".dislikeAction").click(function(){
      var current_post_tr = $(this).parents('tr')[0];
      $.ajax({
        url: 'http://localhost:3000/dashboard/' + $(current_post_tr).attr('data-post_id') +'/dislike',
          type: 'PUT',
          success: function(){
            $(".dislikeAction").hide().fadeOut();
          }
      });
    });
  });
  </code></pre>
  
  <p>So it doesn't hide and then doesn't fade in.</p>