I'm learning OOP javascript... In my example code, I can't access properties and methods from within the ajax methods ... why, and what would be the right way to do that? http://jsbin.com/votajaxo/1/
var Person = function(name){
    this.name = name;
};
Person.prototype = {
    doAjax: doAjax,
    changeName: changeName
};
function doAjax(url){
    console.log(this.name); // John
    $.ajax({
        url: url,
        beforeSend: function(xhr){
            console.log(this.name); // undefined
            console.log(typeof this.changeName); // undefined
            xhr.abort();
        }
    });
}
function changeName(newName){
    this.name = newName;
}
var p = new Person('John');
p.doAjax('/handler');
 
     
     
    