How to update a div with Ajax.BeginForm AND execute a javascript function?

后端 未结 2 837
南笙
南笙 2020-12-16 19:28

I am updating a div with a partial view by using something like this:

<% using (Ajax.BeginForm(\"Action\", \"Controller\",
               new { id=Model.i         


        
2条回答
  •  隐瞒了意图╮
    2020-12-16 19:53

    I kept looking around and found the answer here:

    Assign a Javascript function to AjaxOptions OnSuccess property raise an error - ASP.NET MVC (with the answer that was not selected)

    Quoting Atzu

    If you have to pass any parameter to the OnSuccess event you may have to write the funcion in this way.

    OnSuccess = "function(){exampleFunction('" + param1 + "');}
    

    and it worked for me!

提交回复
热议问题