How to reference an anonymous JavaScript function?
Posted
by ProfK
on Stack Overflow
See other posts from Stack Overflow
or by ProfK
Published on 2010-04-14T21:20:27Z
Indexed on
2010/04/14
21:23 UTC
Read the original article
Hit count: 262
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?
$(":button").click(function () {
var button = this;
PageMethods.DoIt(
function (a, b, c) {
alert(button);
});
});
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?
© Stack Overflow or respective owner