I want to set value for the check when it is unchecked. But every time I post my data whatever it is checked or unchecked, the value will be '1'
I tried to set !isset($check) in post.php, but the value also will be 1.
How can I set the different value when I uncheck the checkbox.
<input type="checkbox" id="check" name="check" value="1">
The jquery code is below:
var check = $('#check').val();
var Data = {check:check};
$.ajax({
type:"POST",
url:"post.php",
data:Data,
beforeSend: function() {
$("#btn-submit").html('sending');
},
success: function(data) {
}
});
:checkedselector.prop('checked')or other ways. Internet is full of tutorials.$('#check').val();change to$('#check').is(":checked");will send true or false depending on state