Write a web application showing the html, AJAX, and all other supporting code to extend the previous lab work book to make an app with an html page using a canvas to scroll real time updates of weather information for Toronto.
Outcome: Make a basic web application that uses the OpenWeatherMap API to fetch weather information for Toronto and display it in a scrolling fashion using a <canvas>.
Note: You'll need to sign up for a free account at
In this JavaScript code, we are using the setInterval function to make an AJAX request to the OpenWeatherMap API every 2 seconds (2000 milliseconds) to get the latest weather information for Toronto. This information is then displayed on the canvas, moving from right to left, creating a scrolling effect.
Please note:
Replace "your-api-key" with your actual OpenWeatherMap API key.
The OpenWeatherMap API is not served over HTTPS on the free tier. This means the application may not work if loaded from a file or a server that is served over HTTPS due to mixed content restrictions. To get around this, you could run a local development server using HTTP.
Make sure the app.js file is in the same directory as your HTML file or adjust the script src attribute accordingly.
This is a basic example and there are many ways you could extend this application. For example, you could display more weather information, style the text to make it more attractive, add error handling if the API request fails, and more.
Learning to work with APIs, AJAX, and the HTML canvas can open up a wide range of possibilities for dynamic, data-driven web applications.
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (