I am using MVC 3 and I have the following controller:
[HttpPost]
public ActionResult Suggest(IEnumerable<Connection> connect)
{
return Json(new { result = true });
}
public class Connection
{
public long Id { get; set; }
public string Name { get; set; }
}
My JQuery looks like:
var connections = $('.on');
var connect = [];
$.each(connections, function (i, item) {
var span = $(item);
var id = span.attr('data-entity-id');
var name = span.attr('data-entity-name');
connect.push({ Id: id, Name: name });
});
$.post('myurl', connect, function (data) {
$('.result').html(data);
});
The JSON binding does not work using this code.