View Single Post
Old 03-09-2007, 03:36 AM   PM User | #5
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Quote:
Originally Posted by Basscyst View Post
I use this little function I wrote, I guess it's creating a new one each time. The only thing I don't like about it is the eval for the call back function, but I can't think of another way to reliably pass values from the initiation of the request to the call back function.
Code:
 var x=4;
 getReqObjPost("someurl.asp","param1=1&param2=2","callBack(xml,"+x+")");

Code:
 var x=4;
 getReqObjPost("someurl.asp","param1=1&param2=2",function() { callBack(xml,x) });
Works fine. The anonymous function creates a closure over all the variables available in the current scope (e.g. x), which then is referenced as an argument to callBack.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote