如何使用ASP.NET MVC控制器动作的jQuery get方法?

时间:2011-07-02 18:42:53

标签: jquery ajax asp.net-mvc-3 partial-views

我想使用部分视图的jQuery get方法。最好的方法是什么?我读到了jQuery get,最简单的方法就是这段代码:

$.get(@Url.Action('Controller', 'Action'), function () { });

1 个答案:

答案 0 :(得分:5)

您只是错过了网址周围的引号,并搞砸了Url.Action帮助器语法。这是正确的方法:

$.get('@Url.Action("Action", "Controller")', function (result) { 
    // TODO: process the results of the server side call
});

请注意传递给$ .get方法的url周围的单引号和Url.Action帮助程序的签名。