2017-10-23 10 views
0

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

$(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!'); 
      } 
     }); 
    }); 
}); 
私のために働いた次を使用して
関連する問題