离开我的 WPF 背景后,我正在学习 Asp.Net MVC。我基本上想单击一个按钮并更新我的模型而不刷新页面。我假设我可以以某种方式使用 AJAX 执行以下操作。
<input class="WelcomeButton" type="button" onclick="location.href='@Url.Action("SetGameType", "Welcome", new { gameType = GameTypes.Expert })'"/>
任何帮助都会很棒。
这是我看完Gent's Link后的进步
<input class="WelcomeButton" id="NoviceButton" type="button" style="left: 157px; top: 442px;"/>
$("#NoviceButton").click(function(){
$.ajax({
url: "@Url.Action("TestMethod", "Welcome")",
type: "post"
});
});
我有一个提交按钮,但没有表单中的按钮...无论哪种方式,上述方法都不适用于该 url 或这个url: "\Welcome\TestMethod",