var dataArray = $('input:checkbox:checked').map(function() {
return this.value;
}).get();
$.ajax({
type: 'POST',
url: 'showdata.php',
data: {data : dataArray},
success: function(data) {
//only the value of last selected checkbox value is returned ,
// but when I alert the dataArray then it shows all values separated with commas.
alert('response data = ' + data);
}
});
显示数据.php
$data = '';
if (isset($_POST['data']))
{
$data = $_POST['data'];
}
echo $data;