So i have a finished method that works and i use it all over the website:
public PartialViewResult GetBlogEntries(int itemsToTake = 5)
{
...
return PartialView("_BlogPost", model);
}
Now i want to get this from my javascript in JSON form.
public JsonResult GetBlogPostJson()
{
var blogEntry = GetBlogEntries(1);
var lastEntryId = GetLastBlogEntryId();
return Json(new {Html = blogEntry, LastEntryId = lastEntryId}, JsonRequestBehavior.AllowGet);
}
Idea is to get it like this:
$.ajax({
url: '/Blog/GetBlogPostJson',
dataType: 'json',
success: function (data) {
var lastEntryId = data.LastEntryId;
var html = data.Html;
...
}
});
Problem is that this of course do not produce a string, but a PartialViewResult.
Question is, how can i resolve the PartialViewResult into html that i can send back with JSON ?