开发者

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

开发者 https://www.devze.com 2023-03-17 02:19 出处:网络
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:

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

精彩评论

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