I know I've had a ton of questions today, but still trying to get everything under control learning MVC 2 tie right way. Before I get into the question I already tried the solution offered here but I get an 500 internal server error.
So here's what I'm trying to do, I give the user the ability to select from a list of skills (loaded in a ListView user control) or add a new one to the list and select that. The adding new one is completed (using a WCF service & jQuery) but now I'm trying to reload the skills user control.
According to the solution I linked to I added an action to my AccountController
public ActionResult GetSkillControl()
{
return View("~/Views/Shared/SkillsListView.ascx");
}
I have the control inside a span (so it has a container)
<tr>
<td style="vertical-align:top;"><label for="SkillsListView" title="Skills">Skills:</label></td>
<td class="regElements"><span id="SkillListViewContainer"> <% Html.RenderPartial("SkillsListView"); %></span><%= Html.ValidationMessageFor(m => m.Skills, "*")%><br />
<span id="AddSkillError"></span>
Add: <input type="text" id="NewSkill" class="inputbox" style="width:75px;" /> <input type="button" value="Add" id="AddSkill" name="AddSkill" /></td>
<td></td>
</tr>
And in my jQuery ajax call I have
success: function () {
$('#SkillListViewContainer').load('../AccountController/GetSkillControl');
}
It's when it reaches that point that the JavaScript console in Chrome shows it returns a 500 internal server error. What am I missing here?
Based on the standard routes in ASP.NET MVC, try "/Account/GetSkillControl". Anything you use from jQuery's load method must be a valid URL. The route engine is looking or Account and not AccountController. Also by using the leading "/" it will resolving from the root of the site.