can anyone help, I have an issue with the keyword this.. before entering the ajax call it’s available but when entering Success. my “this” is available but doesn’t contain the same info i.e. a method I wish to call.. This example shows what I mean..
I would appreciate any help, this.isoDateReviver is available before doing ajax.. and then when success arrives .. this.isoDateReiver is UNDEFINED
var data = new Object();
data.year = this.today = new Date().getFullYear();
this.isoDateReviver("yes", "yes"); //// THIS WORKS HERE
$.ajax({
type: "POST",
url: "MyService.aspx/GetHolidays",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var holidays = JSON.parse(msg.d,
this.isoDateReviver); // THIS DOES NOT WORK its undefined
Calendar.initalizeHolidays(holidays);
},
error: function (msg) {
alert(error);
}
});
its because the success function is executed in a different scope.
you need to do: