ASP.NET MVC controller actions do not return rows. They return ActionResults.
So, start by fixing your action (read below to see why I put italics in italics because this is only the first step):
public ActionResult GetTRAsString(string appID) { // Populate revisions string html = "<ul>"; foreach(RevesionInfo revInfo in revisions) { html += "<li>" + revInfo.RevDesc + "</li>"; } html += "</ul>"; return Content(html, "text/html"); }
Also, the first letter A in AJAX means Asynchronous, so you should put a warning in your success callback, which is the only place where the result will be available:
$.get('/PartialView/GetTRAsString', { appID: appID }, function (data) { alert(data); });
Also remember that generating HTML in a controller action is a terrible idea. Mixing C # and HTML leads to ugliness, which I prefer not to comment on.
In ASP.NET MVC V stands for View, so use them. The purpose of the controller’s action is to select a model and transfer this model to a view for projecting it:
public ActionResult GetTRAsString(string appID) { IEnumerable<Revision> revisions = ... go get your revisions from the DB or something return PartialView(revisions); }
and then your view will be strongly typed for the model, and you will create the necessary markup inside:
@model IEnumerable<Revision> <ul> @foreach (var revInfo in Model) { <li> @revInfo.RevDesc </li> } </ul>
source share