我想通过以下 jQuery 代码将参数从视图传递给操作,但传递参数没有成功。我错过了什么吗?
$('li').click(function () {
employeeID = $(this).attr('id');
window.location.href = '/ApproveWork/GetEmployeeDays/'+employeeID;
});
控制器:
[HttpGet]
public ActionResult GetEmployeeDays(string userCode)
{
.....
return View("GetEmployeeDays", model);
}
从 Global.asax 路由
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
PS 我尝试使用 AJAX jQuery 函数,但这并没有返回我在操作中指定的视图。