How to keep context in javascript methods after call ajax? : <p>hi i have a problem with es6 and in particulary the methods of class. See my exemple :</p>

<p>my first class :</p>

<pre><code>class A{
    constructor(){
         this.B = new B();
         this.test = 5;
    }
    methodA1(){
         B.methodB1(this.methodA2);
    }
    methodA2(){
         console.log(this.test);
    }
}
</code></pre>

<p>the second class :</p>

<pre><code>class B{
    methodB1(callback){
         $.get("url",function(data){
              ...
              callback();
         });
    }
}
</code></pre>

<p>When you execute methodA1, the code return : this is undefined (in a methodeA2) !
In fact when you call a callback function in ajax call the callback lost the context of class. Somebody have an idea to skirt this problem ?</p>

<p>Thanks.</p>
