I am trying to pass a form of checkboxes through ajax. All I really want is a list of all the values of the checked check boxes.
<form id="filters_form">
<input type="checkbox" name="speed" value="1">
<input type="checkbox" name="speed" value="4">
<input type="checkbox" name="accuracy" value="2">
<input type="checkbox" name="measurement-types" value="3">
</form>
This is how I am seriaziling the data
form_val = $('#filters_form').serialize();
$.ajax({
type : 'POST',
url : '//localhost/ajax/filters.php',
data : form_val,
success : function(data) {}
});
The issue seems to be we when more than one checkbox with the same name is checked.
When the data is sent through ajax we have speed+=1&speed+=4&accuracy+=2
But if I print_r($_POST)
then I only get
Array
(
[speed] => 4
[accuracy] => 2
)
It only takes one instance of each name. How can I get the full data?