I work with ASP.NET-MVC. I try to post an array in ajax but I don't know how to get it in my controller. Here is my code :
Ajax
var lines = new Array();
lines.push("ABC");
lines.push("DEF");
lines.push("GHI");
$.ajax(
{
url: 'MyController/MyAction/',
type: 'POST',
data: { 'lines': lines },
dataType: 'json',
async: false,
success: function (data) {
console.log(data);
}
});
MyController
public JsonResult MyAction(string[] lines)
{
Console.WriteLine(lines); // Display nothing
return Json(new { data = 0 });
}
Why I can't see my lines ? How to properly post this array and use it in MyAction ?