G
Gerry Vandermaesen
Hi,
Consider the following code:
var Foo = Class.create();
Foo.prototype = {
initialize: function() {
this.bar = "Hello world";
},
load: function() {
new Ajax.Request("http://www.example.com/", { onSuccess: this.parse
});
},
parse: function(response) {
alert(this.bar);
}
}
foo = new Foo();
foo.load();
My problem is that although load() correctly executes the parse()
function on success, I seem to be in a different scope and all the
object's properties are undefined inside parse(). Anyone know how I
could call this function when the Ajax requests completes successfully,
while staying in the current scope?
Consider the following code:
var Foo = Class.create();
Foo.prototype = {
initialize: function() {
this.bar = "Hello world";
},
load: function() {
new Ajax.Request("http://www.example.com/", { onSuccess: this.parse
});
},
parse: function(response) {
alert(this.bar);
}
}
foo = new Foo();
foo.load();
My problem is that although load() correctly executes the parse()
function on success, I seem to be in a different scope and all the
object's properties are undefined inside parse(). Anyone know how I
could call this function when the Ajax requests completes successfully,
while staying in the current scope?