I used the javascript example code, but instead of "alert" I want it to write into the html, like using "document.write" How do I do this?

  • 1
  • Question
  • Updated 5 years ago
Photo of jmgrant15

jmgrant15

  • 2 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
just use your way of coding, someting like this


<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/THEKEY/geolookup/conditions/q/IA/Cedar_Rapids.json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];

$('body').append("Current temperature in " + location + " is: " + temp_f);
}
});
});
</script>
<body>
</body>
</html>
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
@afelicioni - you rock
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Indeed :), but WU people and service rock too!