Reputation: 29301
First attempt at MVC. Attempting to return a JsonResult. I have this in my controller:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult GetHistoricalReports()
{
JsonResult result = Json("test");
//JsonResult result = Json(DashboardSessionRepository.Instance.HistoricalReports);
return result;
}
and in my view:
function OnHistoricalListBoxLoad(historicalListBox) {
$.getJSON('GetHistoricalReports', function (data) {
alert(data);
}
I have a break-point set inside of GetHistoricalReports and it is indeed being hit. The alert in OnHistoricalListBoxLoad never displays, however.
Upvotes: 3
Views: 1676
Reputation: 5790
You need to return your result like:
return Json("test", JsonRequestBehavior.AllowGet)
Upvotes: 6