我在页面上有一个红色或绿色圆圈的指示器。
<div class="publicBm changeState" currentstate="1" statusid="56" title="This is Public"></div> <!-- green -->
<div class="privateBm changeState" currentstate="1" statusid="57" title="This is Private"></div> <!-- red -->
当用户单击圆圈(如上所示具有类 changeState 的 div)时,将进行 AJAX 调用以将数据库更新为与当前项目相反的状态,公共或私有。然后它返回相反的类。
一切正常,但我想更改单击圆圈上的类以反映更新已成功。
这就是我正在尝试的 - 正如我所说,php文件中的实际数据库调用是完美的,只是div没有改变它的类。
注意 - 每页上可以有多行,所以我不能简单地给 DIV 一个 id
$('.changeState').click(function() {
    var bm_id = $(this).attr('statusID');
    var current = $(this).attr('currentState');
    $.ajax({
        type: "POST",
        url:      '/ajax/actions/editStateBm.php?bm_id='+bm_id+'¤t='+current,
        success:  
            function(data) {
                $(this).removeAttr('class').attr('class', data + ' changeState');
            }
    });
});