title: How to update a div with Ajax.BeginForm AND execute a javascript function?
body: <p>I am updating a div with a partial view by using something like this:</p>
  
  <pre><code>&lt;% using (Ajax.BeginForm("Action", "Controller",
                 new { id=Model.id },
                 new AjaxOptions
                 {
                     UpdateTargetId = "divId",
                     InsertionMode = InsertionMode.InsertAfter,
                 }))
     {  %&gt;
  </code></pre>
  
  <p>and its working fine, the returned view gets appened to the div, however I now need to execute a javascript when the post is successful, so I thought: "easy, just add  <code>OnSuccess = "MyJsFunc()"</code> "  to the <code>AjaxOptions</code>, but after doing this, it stopped working! now the page is refreshed and only the returned partial view is rendered :(, I even tried with a simple <code>Alert("Hi")</code> and its nor working.. how can I get this to work?</p>
  
  <p>(by the way I think this can be a dup of <a href="https://stackoverflow.com/questions/1994754/execute-javascript-after-loading-a-mvc-page-using-ajax-beginrouteform">https://stackoverflow.com/questions/1994754/execute-javascript-after-loading-a-mvc-page-using-ajax-beginrouteform</a> but that question got abandoned with no answer)</p>