【问题标题】:How do I get the source element in the AjaxOptions OnComplete function with MVC Ajax.BeginForm如何使用 MVC Ajax.BeginForm 在 AjaxOptions OnComplete 函数中获取源元素
【发布时间】:2011-03-11 23:50:21
【问题描述】:
作为标题,我需要一些类似...的东西
using (Ajax.BeginForm("MyAction",
new AjaxOptions {
OnComplete = "function() { mySucessFunction(this); }"
}))
<script>
function mySucessFunction(srcElem) {
alert(srcElem.id);
}
</script>
任何指针?谢谢。
【问题讨论】:
标签:
javascript
asp.net-mvc-2
callback
parameter-passing
【解决方案1】:
<% using (Ajax.BeginForm("Create",
new AjaxOptions { OnFailure = "Ajaxerror",
OnBegin="helper_xmlRequestFormControl" ,
OnComplete = "helper_xmlRequestFormSaveEnd",
UpdateTargetId = "form_customer_create"
}))
{ ......... %>
<script >
function helper_xmlRequestFormSaveEnd(obj) {
//obj.get_data() => server response data
//obj.get_request() => ajax object
//obj.get_loadingElement()=> loading elementId
//obj.get_updateTarget()=>updateTarget
//obj.get_response() => Sys.Mvc.AjaxContext
}
</script>