Avatar of Michelle Jackson
Michelle Jackson

asked on 

Sending Checkbox Status

Trying to send checkbox state to PHP page using Ajax. I am able to send he value of the element but I also need to send the state of the button that will determine if the data is added or deleted from the database. Here is what I have.
<script>

 $(document).on('click', '.favorite-resource-checkbox', function(){  
            var resourceValues = $( this ).val();
		    var user = "<?php echo $user_id; ?>";
	 		var id = $(this).attr('id');
           
           $.ajax({  
                url:"file.php",  
                method:"POST",  
                data:{value: resourceValues , user: user},  
                dataType:"text",  
                success:function(data)  
                {  
                     alert(data);  
                    
                }  
           })  
      });		
	
</script>	

Open in new window


Thanks
DatabasesPHPAJAX

Avatar of undefined
Last Comment
Michelle Jackson

8/22/2022 - Mon