我的一个部分页面中有以下代码块。
想知道是否可以在更改Radio Butto选择时发出Ajax请求。
提前谢谢。
@using (Ajax.BeginForm("_QueriesPartial", "Bug",
new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET",
OnFailure = "searchFailed",
LoadingElementId = "ajax-loader",
UpdateTargetId = "Result",
}))
{
foreach (Query query in @Model.queries) {
<div class="radio">
@Html.RadioButton("UserQuery", query.id, new { onclick = "submitform()" })
@Html.Label(query.name, query.name)
</div>
}
}
以下对我有效:
@using (Ajax.BeginForm("Action", "Controller", null,
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "JavascriptUpdateMethod(data, target)",
Url = Url.Action("ActionAjax", "Controller")
}, new { id = AjaxFormId }))
{
@Html.Hidden("ActionMethodArg", f.Id)
<div class="radiobutton-inline">
@Html.Label("Default", new { style="width: 45px;"})
@Html.RadioButton("name", f.Id, trueorfalse,
new { onchange = "$('#AjaxFormId').trigger('submit');" })
</div>
}