I have this controller:
public HomeController : Controller
{
public ActionResult(MyObj[] myObjArr)
{
}
}
public class MyObj
{
public Datetime d {get;set;}
public int x{get;set;}
public string yy {get;set;}
}
My javascript code is the following:
var obj = { d:new Date(), x : 10, yy : 'hello' };
$.ajax({
type: "POST",
url: server,
dataType:"json",
data: {obj,obj},
success: function(data) {
alert(data);
}
});
It simply dont work, i've tried:
$.JSON({obj,obj});
JSON.stringify({obj,obj});
On data but nothing. Every possible combination i've probably tried out but on server side myObjArr just keeps at null, i've tried numerous walkthroghts, i replaced [] to List, ICollection, etc Any suggestions? Thanks.
data: {obj,obj}That's not valid JavaScript. Surely you see theSyntaxErrorin your console.