$.Comment = function() {
this.alertme = “Alert!”;
}
$.Comment.prototype.send = function() {
var self = this;
$.post(
self.url,
{
'somedata' : self.somedata
},
function(data, self) {
self.callback(data);
}
);
}
$.Comment.prototype.callback = function(data) {
alert(this.alertme);
}
When I’m calling $.Comment.send() debugger is saying to me that self.callback(data) is not a function
What am I doing wrong?
Thank you
You don’t want to declare
selfas an argument to the success function. If you remove that declaration, you’ll pick up the local variable, which is what you want. E.g.: