Json, jQuery and ASP.NET MVC

aspnetI’m stacking a few things here related to Json, jQuery and ASP.NET MVC so that I can get to them later on.

JQuery to grab some Json when a web page is loaded:

$(document).ready(function() {
    $.getJSON("/MyController/MyJsonAction", null, function(data) {
//do stuff with data here
}); });

The smallish code in the ASP.NET MVC controller:

public JsonResult GetJson()

{

    return Json(GetList());

}

It’s possible to use anonymous types with Json() as well, which is very useful but may be harder to unit test.

Published Friday, April 03, 2009 2:01 PM by jdanforth
Filed under: , ,

Comments

# ASP.NET MVC Archived Blog Posts, Page 1

Monday, April 06, 2009 12:04 AM by ASP.NET MVC Archived Blog Posts, Page 1

Pingback from  ASP.NET MVC Archived Blog Posts, Page 1