refreshing html.renderaction with ajax request
asp.net-mvc-4, jquery, renderaction
Solution
dateType should be "html", not "json", if your action returns a PartialViewResult:
public ActionResult UserGallery()
{
// do something
return PartialView();
}
and
$.ajax({
url : '@Url.Action("UserGallery")',
dataType: "html",
success: function (result) { success(result); }
});
Problem
I have div that renders image gallery on my page ``` <div id="gallery"> @{ Html.RenderAction("UserGallery"); } ``` I have this function which runs on the completion of a successful upload of a new image ``` function filesUploadOnSuccess(e) { function updateCart() { //var tdata = $(frm).serialize(); // or your data in the format that will be used ?? $.ajax({ type: "GET", //data: tdata, url : '@Url.Action("UserGallery")', dataType: "json", success: function (result) { success(result); } }); }; } function success(result) { $("#gallery").html(result); } ``` the problem is that the gallery div doesnt get updated.