我正在使用Ajax.BeginForm:
@using (Ajax.BeginForm("PostAction", null, new AjaxOptions { HttpMethod = "post", UpdateTargetId = "TargetID", OnComplete = "OnComplete" }, new { @class = "" }))
在javascript方法OnComplete
中如何找到提交的表单? (甚至是目标ID)
我需要访问表单容器的数据属性。
感谢。
答案 0 :(得分:0)
您可以使用类似的内容向您的javascript发送表单的ID或名称
@using (Ajax.BeginForm("PostAction", null, new AjaxOptions { HttpMethod = "post", UpdateTargetId = "TargetID", OnComplete = "OnComplete(xhr, status, 'form1')" }, new { @class = "" }))
的javascript
function OnComplete(xhr, status, formName) {
alert('Submited Form is ' + formName);
}