如何使用MVC Ajax.BeginForm获取AjaxOptions OnComplete函数中的source元素

时间:2010-07-05 16:31:54

标签: javascript asp.net-mvc-2 callback parameter-passing

作为标题,我需要一些类似......

的内容
using (Ajax.BeginForm("MyAction",
                        new AjaxOptions {
                            OnComplete = "function() { mySucessFunction(this); }"
                        }))


<script>
    function mySucessFunction(srcElem) {
        alert(srcElem.id);
    }
</script>

任何指针?感谢。

1 个答案:

答案 0 :(得分:2)

    <% 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>