I want to send array to my action method:
var items = { 'myIdList[]': [] };
$(':checkbox').change(function () {
$(":checked").each(function () {
items['myIdList[]'].push($(this).val());
});
$('#locationsCheckList').submit();
});
$('#locationsCheckList').submit(function () {
$.ajax({
url: this.action,
type: this.method,
traditional: true,
data: { "myIdList": items }...
Action method:
[HttpPost]
public void GetLocations(int[] myIdList)...
items variable have data but when I pass it like this I get null but if I change
data: { "myIdList": items }
with
data: { "myIdList": [1,2,3,4,5] }
it works. When I debug in browser in items variable I have values:
0: "1"
1: "2"
2: "3"
I can't pass array and I don't know why, if it works hardcoded?