当用户选中或取消选中复选框时,我会进行 ajax 调用,保存设置更改。成功后,我会显示一个小标签,通知用户设置已应用,然后将其淡出。我想从单击它到我淡出消息的时间禁用该复选框。我该怎么做?
$('.role-checkbox').click(function () {
var this_control = $(this);
$.ajax({
url: _SITEURL + 'User/EnableDisableRole',
data: JSON.stringify({ data }),
contentType: "application/json;charset=utf-8",
type: 'POST',
success: function () {
var saved_label = $('<span class="label label-success">Saved</span>')
.hide().appendTo(this_control.parent()).fadeIn(500).delay(3000).fadeOut(500);
},
error: function () {
var saved_label = $('<span class="label label-important">Error Saving!</span>')
.hide().appendTo(this_control.parent()).fadeIn(500).delay(3000).fadeOut(500);
}
});
});