|
Encapsulating XmlHttpRequest Calls within JavaScript classes by Acidus at 1:42 pm EST, Dec 11, 2006 |
Or, solving the scope issue of callback functions without resorting to global variables! //set the var so we can scope the callback var _this = this; //callback will be an anonymous function that calls back into our class //this allows the call back in which we handle the response (_onData()) // to have the correct scope. this._request.onreadystatechange = function(){_this._onData()};
|
|
RE: Encapsulating XmlHttpRequest Calls within JavaScript classes by Lost at 6:29 pm EST, Dec 11, 2006 |
Acidus wrote: Or, solving the scope issue of callback functions without resorting to global variables! //set the var so we can scope the callback var _this = this; //callback will be an anonymous function that calls back into our class //this allows the call back in which we handle the response (_onData()) // to have the correct scope. this._request.onreadystatechange = function(){_this._onData()};
Aye, I started doing this once someone on ##javascript on freenode told me so. |
|
|
|