Reputation: 10143
var Box = function(){
this.parm = {name:"rajakvk",year:2010};
Box.prototype.jspCall = function() {
$.ajax({
type: "post",
url: "some url",
success: this.exeSuccess,
error: this.exeError,
complete: this.exeComplete
});
}
this.exeSuccess = function(){
alert(this.parm.name);
}
}
I'm not getting Box object inside exeSuccess method. How to pass Box object inside exeSuccess method?
Upvotes: 52
Views: 25138
Reputation: 630549
Use the context
option, like this:
$.ajax({
context: this,
type: "post",
url: "some url",
success: this.exeSuccess,
error: this.exeError,
complete: this.exeComplete
});
The context option determines what context the callback is called with...so it determines what this
refers to inside that function.
Upvotes: 80