我正在使用 jQuery 回发到我的 Controller ,但我想知道如何将值作为 ActionResult 中的参数传递。例如:
我有一篇 jQuery 帖子:
$.post("Home\PostExample")
但我想包含下拉菜单中的值:
@Html.DropDownListFor(m => m.Example, Model.Example, new { @id = "exampleCssId" })
进入 Action 结果:
[HttpPost]
public ActionResult PostExample(string myString)
{
//TODO: Write contents of ActionResult
}
如有任何帮助,我们将不胜感激。
谢谢。
最佳答案
我认为这应该有效:
$.post("Home/PostExample", { myString: $("#exampleCssId").val() } );
关于c# - 使用 jQuery 回发到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6214327/