I'm trying to return a JSON result (array);
If I do it manually it works
resources:[
{
name: 'Resource 1',
id: 1,
color:'red'
},{
name: 'Resource 2',
id: 2
}],
but I'm having issues rendering by passing it in:
On the view:
resources:@Model.Resources
Which on the controller
public ActionResult Index()
{
...
var model = new Display();
model.Resources = GetResources();
}
public JsonResult GetResources()
{
var model = new Models.ScheduledResource()
{
id = "1",
name = "Resource"
};
return new JsonResult() { Data = model, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
on the model
public JsonResult Resources { get; set; }
But looking at whats rendered in HTML:
resources:System.Web.Mvc.JsonResult
Any ideas where I'm going wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…