Here are the steps,

Step 1: Create the basic structure of your project, View and View Model.

View and View Model

Step 2: Create Controller add Action which will return the JSON result, My Controller is as below. Note I have added action which return the JSON result.
  1. using DropdownGrid.Models;
  2. using System;
  3. using System.Web.Mvc;
  4. namespace DropdownGrid.Controllers
  5. {
  6. public class JSONANDAJAXDemoController: Controller
  7. {
  8. public ActionResult Index()
  9. {
  10. MyMultipleUpdateViewModel obj = new MyMultipleUpdateViewModel();
  11. obj.myTest1ViewModel = new MyTest1ViewModel();
  12. obj.myTest1ViewModel.MyTestUpdate = "Test1";
  13. obj.myTest2ViewModel = new MyTest2ViewModel();
  14. obj.myTest2ViewModel.MyTestUpdate = "Test2";
  15. return View(obj);
  16. }
  17. public JsonResult GetJSONObject()
  18. {
  19. MyMultipleUpdateViewModel obj = new MyMultipleUpdateViewModel();
  20. obj.myTest1ViewModel = new MyTest1ViewModel();
  21. obj.myTest1ViewModel.MyTestUpdate = "Test1" + DateTime.Now.ToString();
  22. obj.myTest2ViewModel = new MyTest2ViewModel();
  23. obj.myTest2ViewModel.MyTestUpdate = "Test2" + DateTime.Now.ToString();
  24. return Json(obj, JsonRequestBehavior.AllowGet);
  25. }
  26. }
  27. }
Step 3: Include jQuery and AJAX in your project.

Include Jquery

Case 4
: Give call for your JSON action as in the following way,

JSON action

This is my AJAX call to JSON action.
  1. <script type="text/javascript">
  2. $(document)
  3. .ready(function ()
  4. {
  5. $('#Submit')
  6. .click(function ()
  7. {
  8. $.ajax(
  9. {
  10. url: '/JSONANDAJAXDemo/GetJSONObject/',
  11. type: 'get',
  12. dataType: "json",
  13. success: successFunc,
  14. error: errorFunc
  15. });
  16. function successFunc(data)
  17. {
  18. $("#Div1")
  19. .html('')
  20. $("#Div1")
  21. .html("Call using JSON Object : " + data.myTest1ViewModel.MyTestUpdate);
  22. $("#Div2")
  23. .html('')
  24. $("#Div2")
  25. .html("Call using JSON Object : " + data.myTest2ViewModel.MyTestUpdate);
  26. }
  27. function errorFunc()
  28. {
  29. alert('MVC controller call failed.');
  30. }
  31. });
  32. });
  33. </script>
Note: You may add table or design in any form of HTML.

Step 5: Include div’s in your code .
  1. <div id="Div1"> Initial State : @Model.myTest1ViewModel.MyTestUpdate </div>
  2. <div id="Div2"> Initial State : @Model.myTest2ViewModel.MyTestUpdate </div>
  3. <input type="submit" value="Load Json Object Data" id="Submit" />
Step 6: Run the project and click on button you will find the JSON data displaying in the Initial view state.

Run the project

On click load button:

Index