I am writing some javascript to get weather information from url. But Google Chrome shows an error:
Uncaught TypeError: Cannot call method 'addEventListener' of null weather.html:37 (anonymous function)
Any suggestions for fixing this? Thanks!
<html> <head> <title>My weather</title> <script type="text/javascript"> function fetchWeather(){ var xmlHttp = new XMLHttpRequest(); </script> </head> <body> <div class="weather" id="weatherWidget"> <div class="weather-loc"></div> <div class="weather-humidity"></div> <div class="weather-temp"></div> <img class="weather-tomorrow" /> <img class="weather-dayaftertomorrow" /> </div> <button id="update">Update</button> </body> </html>
source share