Reputation: 127
i have this problem.
my function is this
$.ajax({
type: "POST",
url: "/controller/CreateList",
contentType: "application/json; charset=utf-8",
traditional: true,
data: JSON.stringify(myvar),
success: function (returnArray) {
}
.....
in my controller i have this action:
public int[] CreateList(List<ERoleCommission> erolecommission){
List<int> intList= new List<int>();
...//populate the List
return intList.ToArray();
}
with debug i see that intList has filled with the right value, so it isn't a c# error, after calling this action from controller the debug return to js function and returnArray = "System.Int32[]", it contains only type. why? thanks
Upvotes: 0
Views: 1667
Reputation: 33865
Without seeing your controller/action I only guess, but my first guess would be that you forget to JSON-encode the data before you return it as an ActionResult from your action. Try something like this in your action:
public JsonResult YourAction() {
// ... do stuff
var yourArrayOfData = CreateList(yourListOfData);
return Json(yourArrayOfData);
}
Upvotes: 5