UPDATED CODE:
Now, I have this code:
<h2>Testing</h2>
<input type="checkbox" name="fruit1" id="id1" class="box">Banana<br /><br />
<input type="checkbox" name="fruit2" id="id2" class="box">Cherry<br /><br />
<input type="checkbox" name="fruit3" id="id3" class="box">Strawberry<br /><br />
<input type="checkbox" name="fruit4" id="id4" class="box">Orange<br /><br />
<input type="checkbox" name="fruit5" id="id5" class="box">Peach<br /><br />
<form id="myForm" action="2.php" method="post">
<input type="submit" id="groupdelete" value="clickme"><br />
</form>
<script src="jquery-1.7.1.js" type="text/javascript"></script>
<script>
$('#groupdelete').on('click', function(){
var names = [];
$('input:checked').each(function() {
names.push($(this).attr("id"));
});
$.post("2.php", { "names" : names }, function(data) {
names = names.join(",");
// do something on success
alert(data); //if everything is working correctly should alert the var_dump here
});
});
</script>
On page 2.php I have this:
<?php
$names = explode(",",$_POST['names']);
var_dump($names);
?>
Which prints: array(1) { [0]=> string(0) "" }
What I am doing wrong???
Zoran
idattribute value that starts with a number is invalid!