刷新使用jQuery MVC2用户控制 [英] Reload MVC2 user control with jQuery

查看:97
本文介绍了刷新使用jQuery MVC2用户控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道今天我有一吨的问题,但仍试图控制住学习MVC 2平手正道的一切。在我进入的问题我已经尝试提供的解决方案,<一个href=\"http://stackoverflow.com/questions/826450/how-can-i-refresh-a-asp-net-mvc-usercontrol-with-jquery\">here但我得到一个500内部服务器错误。

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.

因此​​,这里是我想要做的,我给用户从技能(在ListView用户控件加载)列表中选择或添加一个新的列表,然后选择的能力。在添加新的完成(使用WCF服务与; jQuery的),但现在我想重装技能的用户控件

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.

据我联系我加了一个动作我的AccountController

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;" />&nbsp;<input type="button" value="Add" id="AddSkill" name="AddSkill" /></td>
    <td></td>
</tr>    

在我的jQuery ajax调用我有

And in my jQuery ajax call I have

success: function () {
    $('#SkillListViewContainer').load('../AccountController/GetSkillControl');
}

当它到达点在Chrome中的JavaScript控制台显示它返回一个500内部服务器错误它。缺少什么我在这里?

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?

推荐答案

根据在ASP.NET MVC标准的路线,尝试/帐号/ GetSkillControl。从jQuery的load方法使用任何必须是有效的URL。路由引擎正在或帐户,而不是的AccountController。还通过领先的/,它将从网站的根目录解析。

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.

这篇关于刷新使用jQuery MVC2用户控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆