I have been searching for a way to do this, and I have looked at the several questions posted on here, but I can't obtain all elements of the array I want. Here is the array I'm sending:
function myFunction(e) {
var containerChildren = $("#active").children();
for (i = 0; i < containerChildren.length; i++) {
var announcementarray = new Array();
announcementarray[i] = $('#' + containerChildren[i].id).data("id");
alert(announcementarray[i]);
}
$.ajax({
data:
{
activeid: announcementarray
},
datatype: 'json',
url: '/HumanResources/Announcement/AnnouncementActive',
cache: false,
type: 'POST',
traditional: true,
error: function (result) {
alert(result);
},
success: function (result) {
//alert(result);
}
});
}
However, whenever the controller receives this data, it only shows the last children with the an actual value, all the others are undefined . Here is the declaration of my controller
public ActionResult AnnouncementActive(string[] activeid, string[] inactiveid)
{
}
Any help is appreciated! (I have tried traditional: true, .serialize(), etc)