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)
{
...
}
精彩评论