I am trying to set up a callback in jQuery that correctly binds "this" to the caller. In particular, here is the code I'm working with. I am making an ajax call in an object like this:
Object.prototype.doAjaxCall = function(url) { $.get(url, null, this.handleAjaxResponse ); }
However, in Object.prototype.doAjaxCall , this does not refer to the right thing. I previously worked with Prototype, and I know you need to bind this when you make an Ajax call, but I cannot find the right way to do this in jQuery. Can someone point me in the right direction?
jquery ajax
Sam lee
source share