Possible Duplicate:
Send array to MVC controller via JSON?
I haven't really found a good solution to this so far.
My javascript/jQuery and I try to send the data using ajax.
var val = new Array();
$( ':checkbox:checked' ).each( function ( i )
{
console.log( $( this ).val() );
val[i] = $(this).val();
});
removeSelected(val);
function removeSelected(listOfStuff)
{
$.ajax({
url: '@(Url.Action("removeSelected"))',
type: 'POST',
data: { listOfStuff: listOfStuff },
dataType: 'json',
success: function ( return_data )
{
$( ":checkbox:checked" ).closest('tr').remove();
}
});
And my controller. The array comes in as null.
[HttpPost]
public bool removeSelected ( string[] listOfStuff )
{
//do stuff
}
Any suggestions?