I am trying to add a css class to my button after some ajax:
$('a.vote-up-0').click(function() {
var id = $(this).siblings('.reply-id').val();
var ajax_auth_token = $('#auth_token').val();
$.post('user/?action=ajax', {
vote_type: 'up',
reply_id: id,
auth_token: ajax_auth_token
}, function(data, return_status) {
var json_data = jQuery.parseJSON(data);
switch(json_data.r_message)
{
case "success":
output = "Yay it works!"; // change
alert(output);
$(this).addClass('vote-up-1'); // ** the culprit **
break;
The alert works, however it does not add the class vote-up-1 to it. There are several instances of the same class (i.e. vote-up-0) on the page, so If I change (this) to 'vote-up-0', it changes all of them. Anyone have any ideas?