jQuery code:
if($(this).attr('data-status') == 'Yes'){
alert('if');
$(this).attr("data-status","No");
}
else{
alert('else');
$(this).attr("data-status","Yes");
}
jQuery function code:
$(".Notification").click(function(){
var notification = {
petid: $(this).attr('data-value'),
status: $(this).attr('data-status')
}
var formurl = '<?php echo base_url();?>index.php/Dashboard/notification';
$.ajax({
method: "POST",
url: formurl,
data: notification,
success: function(response){
if($(this).attr('data-status') == 'Yes'){
alert('if');
$(this).attr("data-status","No");
}
else{
alert('else');
$(this).attr("data-status","Yes");
}
}
})
})
HTML Code:
<input type="checkbox" class="Notification" data-value="6" data-status="Yes" checked="">
I am trying to update the value of data-status but it not working. It alerting me if or else. but not updating value.