click function running 2x

click function running 2x

This seems to cylcle through twice when the table row is clicked. I get 4 alerts 'clicked', 'clicked', 'charge updated:0', 'charge updated:1' (if check box is checked when I click, otherwise the last 2 are reversed.)

If that's not weird enough - it doesn't do it every time, but I haven't been able to figure out what causes it or why it would cycle twice most but not all the time.

function clickcharges() {
   $('#cardcharges tr td').click(function() {
    alert('clicked');
   
    var ccid=$(this).parent('tr').attr('id');
    var ck='ck'+ccid;
   
       if ($('input[name='+ck+']').is(':checked'))
      {       
      $('input[name='+ck+']').attr('checked', false);
         $.post('../postingfiles/charge-clearing-cc-one.php',
            {id: ccid, checked:0},
            function(data){
              alert("Charge updated: " + data);
//post page echos back the posted value of 'checked'
            }
           );
      }
      else {
      $('input[name='+ck+']').attr('checked', true);
         $.post('../postingfiles/charge-clearing-cc-one.php',
            {id: ccid, checked:1},
            function(data){
              alert("Charge updated: " + data);
            }
           );
         }

    });
}