I have a div on an ASP.NET MVC page that I would like to populate dynamically (at user request) using jQuery. I currently have jQuery placing a JSON call to my controller, which returns a JSON object, and then I use Javascript to build the HTML manually, which is then placed in the div.
Hang on a minute. Wouldn't it be much easier to get the controller to produce the HTML on its own (using a custom control (.ascx file)), and then just return the string to be placed in the div?
Easier, schmeasier!
My current attempt involves the following javascript:
$('#MyDiv').load("/MyController/GetList");
calling the following controller method:
public PartialViewResult GetList()
{
... create model ...
var result = PartialView("CategoryList", model);
return result;
}
Problem is, I get absolutely no response from the controller. It is called correctly (as proven by a breakpoint), but Firebug doesn't even register a call to the controller in Net view (although the call does show up the Firebug Console window, with a blank response).
Further, a Debug.Print command within the .ascx file produces an output, so the jQuery call and the PartialView method definitely fire.
What is PartialView (and PartialViewResult) used for, and what should I be doing instead of this?
Thanks in advance.
Oh, and it's using the Release Candidate... if that makes a difference.