-1
jQuery代碼:jQuery數據值沒有更新。如何解決這個問題?
if($(this).attr('data-status') == 'Yes'){
alert('if');
$(this).attr("data-status","No");
}
else{
alert('else');
$(this).attr("data-status","Yes");
}
jQuery函數代碼:
$(".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代碼:
<input type="checkbox" class="Notification" data-value="6" data-status="Yes" checked="">
我想更新的數據狀態的值,但它不能正常工作。它提醒我,否則。但沒有更新價值。
BTW ...你的成功*''response'用於什麼? –