Iam*_*ndu 2 c# asp.net-mvc jquery routes
我有一个jquery代码打开一个对话框.该对话框是一个局部视图,它从jquery Ajax调用" http://test.com/ControllerA/ViewDetails" 的响应中呈现.Ajax调用代码如下所示
$.ajax({
url: "ViewDetails",
type: "GET",
dataType: "html",
Run Code Online (Sandbox Code Playgroud)
该对话框有一个按钮,它必须进行另一个Jquery Ajax调用(这违背了不同的控制器和操作).Ajax代码如下所示.
$.ajax({
url: "ControllerB/Search",
type: "GET",
dataType: "html",
Run Code Online (Sandbox Code Playgroud)
上面的ajax调用无法找到搜索操作,因为URL将更改为http://test.com/ContollerA/ControllerB/Search.
我觉得这与路由配置有关.但我需要你们的一些指示.
$.ajax({
url: "@Url.Action("ViewDetails", "ControllerA")",
type: "GET",
dataType: "html",
Run Code Online (Sandbox Code Playgroud)
和
$.ajax({
url: "@Url.Action("Search", "ControllerB")",
type: "GET",
dataType: "html",
Run Code Online (Sandbox Code Playgroud)
这样你就可以使用路由表而不会生成网址了