Request in Javascript (no Jquery)

  • 2
  • Question
  • Updated 5 years ago
Hello,
I would like to answer a forecast in JavaScript (no Jquery), but do you know I have an error?
Thank you

var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://api.wunderground.com/api/myKey...'); //http://api.wunderground.com/api/myKey... is ok

xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
alert(xhr.responseText);
else if(xhr.readyState == 4 && xhr.status != 200) {
alert('error');
}
}
xhr.send(null);
Photo of Raffi Tchoboian

Raffi Tchoboian

  • 7 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 2

Be the first to post a reply!