我正在尝试使用icheck POST到临时表的文件,然后取消选中它以从表中删除该条目。现在,当我选中此框时,它会提醒我并将信息存储到数据库中。每当我取消选中它,似乎什么都没发生。甚至在if语句之前放置警报消息也没有被触发。
复选框
<td><input type="checkbox" class="check" value="76624148" ></td>
Jquery的
$(document).ready(function(){
$('input').on('ifChecked', function(event){
var checked = $(this).is(":checked");
if(checked){
var value = $(this).val();
$.post('functions/jQuery/search/checkBox.php', { value:value }, function(data){
// data = 0 - means that there was an error
// data = 1 - means that everything is ok
if(data == 1){
// Do something or do nothing :-)
alert('Data was saved in db!');
}
});
} else {
var value = $(this).val();
$.post('functions/jQuery/search/uncheckBox.php', { value:value }, function(data){
// data = 0 - means that there was an error
// data = 1 - means that everything is ok
if(data == 1){
// Do something or do nothing :-)
alert('Data was removed in db!');
}
});
}
});
});
答案 0 :(得分:0)
使用以下方法为我工作
$(document).ready(function(){
$('input').on('ifChecked', function(event){
var value = $(this).val();
$.post('functions/jQuery/search/checkBox.php', { value:value }, function(data){
// data = 0 - means that there was an error
// data = 1 - means that everything is ok
if(data == 1){
// Do something or do nothing :-)
alert('Data was saved in db!');
}
});
});
$('input').on('ifUnchecked', function(event){
var value = $(this).val();
$.post('functions/jQuery/search/uncheckBox.php', { value:value }, function(data){
// data = 0 - means that there was an error
// data = 1 - means that everything is ok
if(data == 1){
// Do something or do nothing :-)
alert('Data was removed in db!');
}
});
});
});