Possible Duplicate:
Is there a way for a JQuery ajax success function to access the object it’s contained in?
I have some code like that
myClass.prototype.doStuff = function(){
$.ajax({
type: 'POST',
url: $('#form').attr('action'),
data: $('#form').serialize(),
success: this.callback
});
};
myClass.prototype.callback = function(data){
if(this.someFlag){
//do some stuff
}
};
In this case I supposed this to be the instance of myClass, but it isn’t actually. Why is that?
Pass
context: thisas an ajax option.