我有问题,要求用ajax 一个PartialView在我看来一切看起来找到了点,但错误出现这样的:ASP.NET MVC 3与jQuery Ajax加载一个PartialView
请求URL:http:/ /本地主机:4530 /主页/ ViewWorld 请求方法:GET 状态代码:404未找到
这里是代码:
$.ajax({
url: "Home/ViewWorld", //'@Url.Action("viewWorld", "Home")',
type: "GET",
dataType: "html",
success: function (e) {
alert(e);
},
error: function (error) {
alert(error[0]);
}
});
我的控制器是这样的:
public class HomeController : Controller
{
//
// GET: /Index/
public ActionResult Index()
{
return View();
}
[HttpGet]
public ActionResult ViewWorld()
{
return PartialView("_ContactMe");
}
}
的Global.asax:
routes.MapRoute("Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home",
action = "ViewWorld",
id = UrlParameter.Optional } // Parameter defaults
);
谁能帮助我弄清楚为什么它不工作,感谢
如果您在浏览器中打开URL(http:// localhost:4530/Home/ViewWorld),会发生什么情况?你可以访问任何其他行动? – Pbirkoff 2012-01-12 22:25:50
你有没有为该行动设立的路线? – 2012-01-12 22:27:49
错误显示: 描述:HTTP 404.您正在查找的资源(或其某个依赖项)可能已被删除,名称已更改或暂时不可用。请检查以下网址并确保它拼写正确。 请求的URL:/首页/ ViewWorld – Danny 2012-01-12 22:30:03