Consider the following code:
MyClass.prototype.my_func = function () {
this.x = 10;
$.ajax({
// ...
success: function (data) {
The closure will have access to all objects defined in its parent's context. So if we have:
function() {
var x = 10;
}
Then this is valid:
function() {
var x = 10;
(function() {
alert(2*x); // 20
}())
}
Therefore, when you define var _this = this
you have merely defined a new variable in the parent's context that is available within the closure. See question #4371333 for more information on this "pattern."