I want to check the checkBox's value in php
. Either selected or not. I am trying in a way;
JQuery
<script type="text/javascript">
$(document).ready(function(){
$("#save").click(function(){
var checkBox = $("#boxV").is(':checked');
$.ajax({
url: "http://localhost/testing/test.php",
type:"POST",
async:true,
data:{
"done":1,
"checkBox" : checkBox
},
success: function(data){
$('#result').append(data);
}
});
});
});
</script>
PHP
<?php
if(!isset($_POST['checkBox'])){
echo ('0');
}else{
echo ('1');
}
?>
HTML
<li><input type="checkbox" id = "boxV" > Check</li><br>
The problem is that both times (Selected , not selected) the result
div is filled with 1
. Is there any problem?