I want to display a json string returned in the result of an ajax call in the from of a table. My ajax code is :
var table = $('#PartnersTable');
$.ajax({
type: "GET",
url: '@Url.Action("Get","Home")',
dataType: 'json'
}).done(function (data) {
// Code here
});
I have tried many solution , that are on stackoverflow but they didn't work. Thanks in advance
This is my action code :
public ActionResult Get()
{
Home h = new Home();
return Json(h.get(), JsonRequestBehavior.AllowGet);
}
considering that your h.get() method will returns object which has following properties...
{"Homes"
:[
{"ID":2,"Name":"Hammad"},
{"ID":3,"Name":"dsda"}
]
}
These values will get accessed in following manner
data.Homes[0].ID
data.Homes[0].Name