문제

i need to pass a list of object to View from controller using Json , what the syntax of java-script to access the list objects and its properties then add them into data table ?

올바른 솔루션이 없습니다

다른 팁

In Controller You need use anonymous object to return json data

var result = // object which contain result
var jsonData = result.select(x=>new{
   PropertyA = x.A,
   PropertyB = x.B,
   PropertyC = x.C,
});

return Json(jsonData, JsonRequestBehavior.AllowGet)

In function javascript

success:function(data){
 $.each(data,function(i,data){
    //loop and insert your table
    data.PropertyA //get data  
})
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top