Using object's method as callback function for $.post
Posted
by Kirzilla
on Stack Overflow
See other posts from Stack Overflow
or by Kirzilla
Published on 2010-04-16T10:22:18Z
Indexed on
2010/04/16
10:23 UTC
Read the original article
Hit count: 185
jQuery
Hello,
$.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
© Stack Overflow or respective owner