I have the following code in JavaScript and jQuery with an integrated ajax request.
Question: Why is it possible to call the inner function success1()
but it is not possible to call this.success2()
? Any solution proposals for this problem?
function myfuntion() {
this.url = "www.example.com/ajax.php";
var success1 = function (data) {
alert("SUCCESS1");
}
this.success2 = function (data) {
alert("SUCCESS2");
}
this.send = function () {
$.ajax({
type: "POST",
url: this.url,
dataType: "html"
}).done(function (data) {
success1(data);
this.success2(data);
});
}
}
var test = new myfunction().send();