1//You can call a Partial View through AJAX
2
3<div id="containerId"></div>
4
5$.ajax({
6 type: "Get",
7 url: '<Your url>/GetView',
8 data: mydata,
9 contentType: "application/text; charset=utf-8",
10 dataType: "text",
11 success: function (data, status) {
12 //Use append to add it to the div and not overwrite it
13 //if you have other data in your container
14 $('#containerId').append(data);
15 },
16 error: function (err) {
17 console.log(err);
18 }
19});
20
21//In C#
22
23/// <summary>
24/// Renders a single view.
25/// NOTE : PARTIAL VIEW CANNOT RENDER MULTIPLE VIEWS!
26/// Instead loop through them.
27/// </summary>
28/// <param name="obj">JSON object containing input data</param>
29/// <returns></returns>
30[HttpGet]
31public ActionResult GetView(string obj)
32{
33 //Parse the object into a model
34 try
35 {
36 MyModel model = (new JavaScriptSerializer()).Deserialize<MyModel>(obj);
37 return View("<Your View name>", obj);
38
39 }
40 catch (Exception ex)
41 {
42 return Json(ex.Message, JsonRequestBehavior.AllowGet);
43 }
44
45}