在我的网站上,我使用 jquery ajax 将数据发送到 Controller 。如何使用 jquery/javascript 对数据进行编码,以便我可以发送 JavaScript 代码等字符串?
谢谢
最佳答案
您可以使用.ajax()
方法:
$.ajax({
url: '/somecontroller/someaction',
type: 'POST',
data: { value: 'some string' },
success: function(result) {
// ...
}
});
和 Controller 操作:
[HttpPost]
public ActionResult SomeAction(string value)
{
...
}
关于jquery - ASP.NET MVC + 使用 jquery ajax 发送编码字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5927597/