I am trying to show a modal pop up by making a getjson call like this from my javascript:
$.getJSON('/Home/somefunction', function(result) {
var toto = $(result);
alert(toto);
});
public ActionResult somefunction()
{
return new JsonResult { Data = PartialView("modal pop up partial view") };
}
My modal pop up view is partialview.
Thanks
The better way is to return a PartialView from the controller. Use $.get
or $.ajax
to make a GET request to the server (or a POST if you need), and the callback will have the HTML. You can then inject the HTML into the parent view (inside the modal).