I got problem to request a PartialView using ajax In my point of view everything looks find, but error show up like:
我有问题使用ajax请求PartialView在我的观点中,一切看起来都找不到,但错误显示如下:
Request URL:http://localhost:4530/Home/ViewWorld Request Method:GET Status Code:404 Not Found
请求URL:http:// localhost:4530 / Home / ViewWorld请求方法:GET状态代码:404 Not Found
Here are the codes:
以下是代码:
$.ajax({
url: "Home/ViewWorld", //'@Url.Action("viewWorld", "Home")',
type: "GET",
dataType: "html",
success: function (e) {
alert(e);
},
error: function (error) {
alert(error[0]);
}
});
My controller look like this:
我的控制器看起来像这样:
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
);
Can anyone help me to figure out why it does not works, thanks
任何人都可以帮我弄清楚它为什么不起作用,谢谢
1 个解决方案
#1
1
You are just missing a forward slash: "/Home/ViewWorld"
你只是错过了正斜杠:“/ Home / ViewWorld”
#1
1
You are just missing a forward slash: "/Home/ViewWorld"
你只是错过了正斜杠:“/ Home / ViewWorld”