How to reference an anonymous JavaScript function?
<p>I'm trying to call a Page Method using a jQuery 'attached' event function, in which I like to use the closure to keep the event target local, as below, but page method calls declare several 'error' functions, and I would like to use one function for all of them.  If, in the below code, I was handling an error and not success, how could I use my single, anonymous handler for all 3 error functions?</p>

<pre><code>        $(":button").click(function () {
            var button = this;
            PageMethods.DoIt(
                function (a, b, c) {
                    alert(button);
                });
        });
</code></pre>

<p>This example passes an anonymous function for the success callback.  There is only one of these.  If I was passing an error callback, how could I use 'function (e, c, t)' for all 3 error callbacks?</p>

<p>ADDED:  What I would like to do here is trigger an AJAX call whenever the user clicks a toggle button (checkbox), but to improve responsiveness, I want to toggle the button state immediately, and only 'untoggle' it if the AJAX call fails.</p>

<p>Now, in my client-side <code>click()</code> event handler, I would like to use anonymous functions inside the scope of <code>click()' so that the functions have access to the</code>this<code>event argument, but I don't want to 'declare' three functions for the</code>onTimeout<code>,</code>onError<code>, and 'onAbort</code> arguments of the PageMethods.MyFunction function.  if I declare a named function outside of the click handler, it no longer has access to the 'this' parameter of the <code>click()</code> event handler.</p>
