pass optional function as parameter to another function
<p>Options of how I want to call a function:</p>

<pre><code>myAjax("http://ajaxurl.com", { prop: val }, function(resp) { alert(resp); });
</code></pre>

<p>or</p>

<pre><code>function handleSuccess(resp) { alert(resp); }
myAjax("http://ajaxurl.com", { prop: val }, handleSuccess);
</code></pre>

<p>or</p>

<pre><code>myAjax("http://ajaxurl.com", { prop: val }, null);
</code></pre>

<p>or</p>

<pre><code>myAjax("http://ajaxurl.com", { prop: val }); // param not even provided
</code></pre>

<p>How can I handle this on the myAjax function definition?  Something like this...?</p>

<pre><code>function myAjax(url, jsonData, successFunc) {
  $.ajax({
    ... all the necessary ajax stuff that normally goes here
    , success: function(response) {
      // custom myAjax success handling goes here. this must happen before optionally-passed-in successFunc gets executed

      // what goes here? this?
      if (typeof successFunc != 'undefined' &amp;&amp; successFunc != null) {
        successFunc(response);
      }
    }
  });
}
</code></pre>

<p>I tried something like the above, but, it did not call the success function.  Do I need to check if successFunc is a function?</p>

<p>Thanks!</p>
