When is it typical to use the JsonResult action in an ASP.NET MVC 3 application?
From where is the JsonResult usually called; from another action or an actionlink rendered in the html?
Can you give me some examples where you want json instead of a typical view?
Say, for example you wanted to populate a jQuery autocomplete with a list of values based on a selection of another field, so you can’t determine the data on page load. I would typically call an action method in a
$.ajaxcall, then return an array of items to populate the autocomplete with.Example, here’s my jQuery, one function for the call and another that gets called to populate the automcomplete with received data:
And here is my controller:
And here’s the method signature for the method that’s called:
And for clarity, here’s the
HomeInfoclass: