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. RE: Encapsulating XmlHttpRequest Calls within JavaScript classes |