您的第一次尝试已经结束,但是正如您所说的,您无法
this在回调内部进行访问,因为它引用了其他内容。而是
this在外部作用域中分配另一个名称,然后访问该名称。回调是一个闭包,可以在外部范围内访问该变量:
function Property(price, deposit){ this.price = price; this.deposit = deposit; var property = this; // this variable will be accessible in the callback, but still refers to the right object. this.getMortgageData = function(){ $.getJSON('http://example.com/index?p='+this.price+'&d='+this.deposit+'&c=?', function(data){ property.mortgageData = data; }); } return true;}


