jQuery
$("input[type=checkbox]:checked").live("click", function (e) {
var data = $('.variation:checked').map(function (i, n) {
return {
'val': $(n).val()
};
}).get();
$.post('/variations.php', {
'data': data
}, function (data) {
$('#variations').html(data);
});
});
HTML output
<div id="variations">
Array
(
[data] => Array
(
[0] => Array
(
[val] => 1
)
)
)
</div>
PHP
print_r($_POST)
Question: How do I remove value from POST if checkbox is unchecked?
you can use .disable method to disable object and then when posting is finished enable them.or you can use method .click function when submit button clicked or if you want to dont use this values in your php you can unset($_POST[‘one certain key’]) with unset function