0

I have problems to get data from Weather Underground from a historical day (same script works fine for my current observations). Example for yesterday:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>

heute=new Date(); 
jahr=heute.getFullYear(); 
monat=heute.getMonth()+1; 
tag = heute.getDate()-1;

jQuery(document).ready(function($) {
  $.ajax({
  url : "http://api.wunderground.com/api/ea1cb0c0f1995212/history_'+jahr+monat+tag+'/q/pws:INORDRHE156.json",
  dataType : "jsonp",
  success : function(parsed_json) {


 var minhumidity = parsed_json.history.dailysummary[0].minhumidity; 
 var day = parsed_json.history.dailysummary[0].date.pretty;
 document.getElementById("z8").innerHTML = minhumidity;
 document.getElementById("z9").innerHTML = date; 

  }
  });
});
</script>

So "day" works for me, output is: November 13, 2017

But "minhumidity" should bei '90' (or some other value), but there will be just a blank.

I get both values (day and minhumidity) at the same way, where is the Problem?

Sorry for my english.

2
  • You should use the dev tools to get a look at the json returned from the API and post that here. Nov 13, 2017 at 15:36
  • It was my first post, so pls forgive me ;-)
    – TornadoS
    Nov 13, 2017 at 16:07

1 Answer 1

2

your url "http://api.wunderground.com/api/ea1cb0c0f1995212/history_'+jahr+monat+tag+'/q/pws:INORDRHE156.json" change it to (note that i changed ' with "):

<script>

heute=new Date(); 
jahr=heute.getFullYear(); 
monat=heute.getMonth()+1; 
tag = heute.getDate()-1;

jQuery(document).ready(function($) {
  $.ajax({
  url : "http://api.wunderground.com/api/ea1cb0c0f1995212/history_"+jahr+monat+tag+"/q/pws:INORDRHE156.json",
  dataType : "jsonp",
  success : function(parsed_json) {


 var minhumidity = parsed_json.history.dailysummary[0].minhumidity; 
 var day = parsed_json.history.dailysummary[0].date.pretty;
 document.getElementById("z8").innerHTML = minhumidity;
 document.getElementById("z9").innerHTML = date; 

  }
  });
});
</script>

And please add var, let, const whatever to your variables. For example:

var heute = new Date(); 
var jahr = heute.getFullYear(); 
var monat = heute.getMonth()+1; 
var tag = heute.getDate()-1;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.