index.html
<form action="/add.php" method="post" class="form_in" data-action="add">
<input id="name" name="name" type="text" autofocus>
<input id="check" name="check" type="checkbox">
<button type="submit">ADD</button>
</form>
add.php
if (isset($_POST['check'])){
echo "1";
}
else{
echo "0";
}
Если без аякс, работает. Если с, все время 0.
$(function(){
$(document).on('submit', '[data-action="add"]', function (e) {
e.preventDefault();
$.ajax({
url: this.action,
type: this.method,
data: {
name: this.name.value,
check: this.check.value
}
}).done(function (data) {
$(".stat_ok").html(data);
$(".stat_ok").fadeIn();
});
});
});