mates,
I am still failing to retrive any data from my controllers. All I am getting is [object],[object],[object],[object] as results. My code is as below:
———————————————————————————————————–
the code part that sends the request to the controller on the server from the view
————————————————————————————————————
@model IEnumerable
@{
ViewBag.Title = “Index”;
}
$(document).ready(function(){
var theme = getDemoTheme();
var title =’Department Details’;
var url = ‘/Department/GetDepartments’;
var rowdata =[];
$.ajax({
type: ‘POST’,
url: url,
datatype: ‘json’,
success: function(data){
//rowdata = data;
alert(data); //here I am alerting just to see the results
}
});
—————————————————————————————–
the controller code
—————————————————————————————–
[HttpPost]
public JsonResult GetDepartments()
{
var result = db.Departments.ToList();
var departments = from d in result
select new {d.DeptID,d.DeptName};
return Json(departments);
}
Where Am I going wrong?