I'm passing an array from form inputs (checkboxes) using the get method. When doing in ajax, with:
var subcat_checked = new Array();
$.each($("input[name='subcategories']:checked"), function() {
subcat_checked.push($(this).val());
});
$.ajax({
type: 'GET',
url: '{% url view-category root_category.slug %}',
data: {subcat: subcat_checked},
success: function(result) {
/* stuff */
},
dataType: 'json'
});
the variable key is 'subcategories' when no checkbox is checked, and 'subcategories[]' when some are checked.
Now, when sending it using a non-ajax form and some checkboxes are checked, the variable key is 'categories' (with no [] at the end).
Since I'd like to use the non-ajax form as a fallback if javascript is disabled, I'd like to have the same key when some checkboxes are checked.
Anybody knows how I can do that?
Thanks