[Project_owners] Callback functions

Stan James sjames at uni-osnabrueck.de
Tue Apr 5 15:19:21 EDT 2005


Hi all,

I have a question about callback functions, like onreadystatechange for 
XMLHttpRequest(). What is the best way to pass state information to 
these functions? I find myself setting lots of global variables which 
are then read in by the callback function, because this seems to be the 
only way to pass information it information.  But this goes against all 
my "good programming style" instincts. Plus, if I fire off 10 
XMLHttpRequests at once, it seems ridiculous to need 10 separate 
callback functions. Am I missing something obvious?

I even toyed with creating the callback functions dynamically, but this 
seems like a worse offense than using global variables!

Thanks for any insight.

-stan


More information about the Project_owners mailing list