Possible help for Javascript "Uncaught TypeError" / Undefined

  • 1
  • Idea
  • Updated 5 years ago
I was getting "Uncaught Type Error" / undefined using the sample Javascript / jQuery code in the documentation when querying a station for which no report was available. Thought this might help others in a similar situation, as I couldn't find it in the forum search:

excerpted from the sample code....

success : function(parsed_json) {

// insert this to the sample code
if (parsed_json['response']['error']) {
// generate error message or action
} else {
// resume sample code

var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);
}
Photo of LochAwe

LochAwe

  • 1 Post
  • 0 Reply Likes

Posted 5 years ago

  • 1

Be the first to post a reply!