I have a simple javascript array. it's declared like this:
coords = []
and everytime a user clicks on an image, I do something like this:
coords.push([x,y])
so I end up with something like this: (in javascript)
[[342,144],[477,99],[632,148],[529,162]]
but I don't know what to bind it to in the controller method... I've tried
List<List<int>>, int[][], int[,]
none of them seem to work. It only works when I use string.
This is the code I'm using to send it to the server:
$.ajax({
type: "POST",
url: "/home/SaveCoords",
data: { coords: JSON.stringify(coords) }
}).done(function (msg) {
alert("Data Saved: " + msg);
});
And this is the code I use on the controller
[HttpPost]
public ActionResult SaveCoords(string coords)
{
return Json("Hello", JsonRequestBehavior.AllowGet);
}
Help?