Подскажите, что не так. После обращения к прототипу Weather.geton выдаётся ошибка «is not a function». В функциональном стиле всё работает без ошибок.
function Weather(url) {
this.geton(url);
console.log(url);
}
Weather.prototype.geton = function(url) {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true );
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
this.successH(xhr.response);
} else {
this.errorH(status)
}
}
xhr.send();
}
Weather.prototype.successH = function(data) {
if (typeof data == 'string') {
return;
} else {
console.log(data);
}
}
Weather.prototype.errorH = function(err) {
return
}
thisвнутриxhr.onload = function() {не тот же самый что снаружи – Grundy Apr 27 '16 at 14:26