Does the model binder not suport arrays of JSON objects? The code below works when sending a single JSON domain object as part of the ajax post. However, when sending an array o
I had a similar problem. To solve it, I took a slightly different approach. Instead of a JSON object, I used arrays of hidden form variables. As long as the variable names matched up, model binding worked like a charm.
function AddDomainBasket(domainName, price, available) {
if ( typeof AddDomainBasket.counter == 'undefined' ) {
AddDomainBasket.counter = 0;
}
$("#some_form").append('');
$("#some_form").append('');
$("#some_form").append('');
++AddDomainBasket.counter;
}
And then submit the serlialized form
$(this).parents('table').find('input:checked').each(function () {
AddDomainBasket($(this).parent().parent().find('.name').html(),
$(this).parent().parent().find('.price span').html(),
$(this).parent().parent().find('.available').html() == "Available");
}
});
$.ajax({
type: 'POST',
url: Url.BasketAddDomain,
data: $('#some_form').serialize(),
success: function (basketHtml) {
},
error: function (a, b, c) {
alert('A problem ocurred');
}
});