Tell me what's wrong. After accessing the prototype of Weather.geton error “is not a function” is displayed. In the functional style, everything works without errors.
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 }
thisinsidexhr.onload = function() {not the same as outside - Grundy