My problem is as simple as the title.. I have some code which makes an AJAX call. This code is similar to this (JSFiddle):
function Test() {
this.name = "U don't wanna know my name..";
}
Test.prototype.ajax = function() {
$.ajax("url/path", data, function() {
alert(this.name);
});
};
var test = new Test();
test.ajax();
In this case this
is undefined. I could place the following code before the ajax call and use that in stead of this
:
var diz = this;
I was wondering if there's another way of using this
without creating a new variable for it.