我是JS新手,遇到了用XHR对象实现的AJAX代码。因此,您可以在下面看到:
function easyHTTP() {
this.http = new XMLHttpRequest();
}
// Make an HTTP GET Request
easyHTTP.prototype.get = function(url) {
this.http.open('GET', url, true);
this.http.onload = function() {
if(this.http.status === 200) {
console.log(this.http.responseText);
} else {
console.log('Error: ' + this.http.status);
}
}
this.http.send();
}
那么,if语句中的此关键字引用了什么?如果它引用了等于onload的函数,那为什么呢?我认为这引用了一个对象,该对象执行的是easyHTTP的均衡功能。我说的对吗?