I'm trying to retrieve a group of checkbox values, store into an array, and then use that array in my ajax data parameter.
I am getting an error back from my page stating that the data is not in the correct format. It needs to be an ienumerable.
Here is what I have so far:
var years = new Array();
$("#years input:checkbox[name=type]:checked").each(function() {
if (checked == true) {
years.push($(this).attr('name') + "=" + $(this).val());
}
});
var ajaxData = years;
$.ajax({
type: "POST",
url: url,
dataType: "json",
data: ajaxData
});
How can I convert the array to a list-like format?
Thanks!
checkeddoing? Also, shouldn't that statement always return true since you're only selecting "checked" checkboxes?