开发者

How to use jQuery get method with ASP.NET MVC controller actions?

I want to use jQuery get method with a partial view. What is the best way to do it? I read about jQuery get and the simplest way to me is this code:

$.get(@Url.Action('Cont开发者_Go百科roller', 'Action'), function () { });


You are just missing quotes around the url and have messed up the Url.Action helper syntax. Here's the correct way:

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

Notice the single quotes around the url passed to the $.get method and the signature of the Url.Action helper.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜