Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
<meta charset=utf-8 />
<title>Welcome to JS Bin</title>
<meta name="viewport" content="width=device-width">
<link href='http://fonts.googleapis.com/css?family=Doppio+One' rel='stylesheet' type='text/css'>
</head>
  
<body>
  
  <button type="submit" class="btn btn-primary button_like"><span class="glyphicon glyphicon-thumbs-up"></span> Like</button>
  
   <button type="submit" class="btn btn-primary button_like"><span class="glyphicon glyphicon-thumbs-up"></span> Like</button>
  
   <button type="submit" class="btn btn-primary button_like"><span class="glyphicon glyphicon-thumbs-up"></span> Like</button>
  
</body>
</html>
 
  $('.button_like').one('click', function(e) {
    
    e.preventDefault();
    alert('click');
    
    var data = {
      user_id: '5',
      post_id: '6',
      ajax: '1' 
    };
    var $this=$(this);
    $.ajax({
      url: "/",
      type: 'POST',
      data: data,
      success: function() {
       $this.addClass('btn-success')
            .removeClass('btn-primary')
            .html('<span class="glyphicon glyphicon-thumbs-up"></span>');
      },
      error: function(xhr, textStatus, errorThrown) { 
                alert("Status: " + textStatus); alert("Error: " + errorThrown); 
            }
  
    });
  //  return false;
  });
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers