using js in partial viewi n aspnet core mvc 5 code example
Example: mvc asp.net partial view from js
<div id="containerId"></div>
$.ajax({
type: "Get",
url: '<Your url>/GetView',
data: mydata,
contentType: "application/text; charset=utf-8",
dataType: "text",
success: function (data, status) {
$('#containerId').append(data);
},
error: function (err) {
console.log(err);
}
});
[HttpGet]
public ActionResult GetView(string obj)
{
try
{
MyModel model = (new JavaScriptSerializer()).Deserialize<MyModel>(obj);
return View("<Your View name>", obj);
}
catch (Exception ex)
{
return Json(ex.Message, JsonRequestBehavior.AllowGet);
}
}