Losing 'this' focus in event listener
I'm working on an Ajax class - though my question isn't really about Ajax at all..
On line 47 I setup a listener onreadystatechange.
The problem is that when Ajax.stateChangeHandler() is called
// Setup listener on readystatechange
this.xhr.onreadystatechange = stateChangeHandler;
I have lost a reference to the Ajax object using 'this'
So I am just using Ajax.variable to access it's properties / methods - This works but it feels kind of hacky.
Is there a way to keep the object focus within an event listener?