Ich möchte eine Ajax-Anfrage, die immer noch Zugriff auf das aktuelle Objekt behält. Weiß jemand, ob das möglich ist?Javascript OOP - jQuery Aufruf "dieses" in Ajax-Anfrage
Beispiel von dem, was ich tun möchte:
function mobile_as(as_object, inputID) {
this.object = 'something';
if (as_object) this.object = as_object;
this.inputID = inputID;
// Get results for later usage.
this.get_results = function(value) {
this.request = $.getJSON("URL", { as: this.object }, function (data) {
// Scope of "this" is lost since this function is triggered later on.
if (data['status'] == "OK") {
alert(this.inputID);
}
});
}
}
}
FYI Javascript OOP nicht. – jrummell
@jrummell Das ist subjektiv, nicht wahr? http://stackoverflow.com/questions/107464/is-javascript-object-oriented – teynon
Ich denke nicht, aber Sie sind frei zu widersprechen. – jrummell