Browse Source

correcting mistakes at homework 11

Krabonub 6 years ago
parent
commit
5a5e661b64
1 changed files with 6 additions and 1 deletions
  1. 6 1
      homework11/index.js

+ 6 - 1
homework11/index.js

@@ -63,8 +63,13 @@ request.onreadystatechange = function(){ //обработчик изменени
                return;
           }
           if (weatherRequest.status == 200){
-            weatherObj=JSON.parse(weatherRequest.responseText);
             var div=document.getElementById("weather");
+            if(city.value=="-Выберете город-"||country.value=="-Выберете страну-"){
+              div.innerHTML="";
+              return;
+            }
+            div.innerHTML="";
+            weatherObj=JSON.parse(weatherRequest.responseText);
             var divs=[];
             var j=0;
             for(var i=0;i<weatherObj.query.results.channel.item.forecast.length;i++){