I need to get a list from mvc controller to view using jquery ajax. But I get [object Object].
Ajax code
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
url: '/Home/getList',
success: function (data) {
debugger;
$scope.StuList = data;
alert(data);
}
});
In Controller
public JsonResult getList()
{
Models.clsSave obj = new Models.clsSave();
var list = new List<Model>();
list= obj.getList();
return Json(list,JsonRequestBehavior.AllowGet);
}
alert(data)useconsole.dir(data)and look in the browser console window. The alert window will only give you a type (in this case object) unless it's a simple type (string/int etc).