开发者

ASP.NET MVC + sending encoded string using jquery ajax

On my website, I'm using jquery aj开发者_如何学运维ax to send data to a controller. How can I encode data using jquery/javascript, so I can send strings like javascript code, etc ?

Thanks


You could use the .ajax() method:

$.ajax({
    url: '/somecontroller/someaction',
    type: 'POST',
    data: { value: 'some string' },
    success: function(result) {
        // ...
    }
});

and the controller action:

[HttpPost]
public ActionResult SomeAction(string value)
{
    ...
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜