[Project_owners] Callback functions

Didier Ernotte didier at ernotte.com
Tue Apr 5 07:16:54 EDT 2005


Hi,

Personnaly, I hate global variable, this is againt my OO education...
I, instead, set all variables on the XMLHttpRequest object itself.
ie.

  var request = new XMLHttpRequest();
  request.myStatus = myStatus;
  request.myValue = myValue;


and then, I retrive these value with  request.myStatus in the
onreadystatechange method.

Didier

--- Stan James <sjames at uni-osnabrueck.de> wrote:
> 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
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
> 


More information about the Project_owners mailing list