I create class. Everything work, but success function not redirect. Why?
class Ajax {
constructor(url, method, dataType, reDirect, alert) {
this.url = url,
this.method = method,
this.dataType = dataType,
this.reDirect = reDirect,
this.alert = alert
}
getAJAX() {
$.ajax({
url: this.url,
method: this.method,
dataType: this.dataType,
success: function(result) {
window.location = this.reDirect
},
error: function(result) {
alert(this.alert)
}
})
}
}
This is how I call a method from the class:
const clearConf = new Ajax('/ConfigurationHistories/ClearList', 'GET', 'text', '/ConfigurationHistories/Index', 'Not clear list.')
clearConf.getAJAX()