From the course: JavaScript: Async
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Implementing callbacks for problem-solving - JavaScript Tutorial
From the course: JavaScript: Async
Implementing callbacks for problem-solving
- [Instructor] Let's take a look at what a callback function looks like in practice. We're going to work with the fictitious Explore California site, and we're going to implement a feature using a callback. We want to add a feature to the tours page that shows the current weather in Los Angeles. Here's what that looks like in the end file for this video. We're going to create an Ajax request to OpenWeatherMap to get current weather data for L.A. And then we want to incorporate the data that's returned into the DOM so it's displayed in the browser window. And so to do that, I want to create an XML HTTP request object. So I'm going to create that here. I'm going to call it httpRequest and set that to new XMLHttpRequest. And then my plan is to create a function called get where I can pass in a URL to actually make that HTTP request. So I'll create a function called get. Parameter name will be URL. And we'll start by…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.