title: Ajax.BeginForm call JS function OnBegin
body: <p>Hi regarding <a href="https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/function-declarations.html" rel="nofollow">https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/function-declarations.html</a> I define my JS function like this</p>
  
  <pre><code>&lt;script language="javascript"&gt;
      var clearMessage = function ClearMessage() {
          $("#result").html("");
      };
  &lt;/script&gt;
  </code></pre>
  
  <p>And I try to call it in OnBegin method from MVC ajax,</p>
  
  <pre><code>@using (Ajax.BeginForm(new AjaxOptions() { HttpMethod = "post", OnBegin = "ClearMessage" }))
  </code></pre>
  
  <p>But I getting error that function not exit,
  how to call my function that described by this best practice ? (without <em>var clearMessage</em> evering working correct)</p>