From the course: JavaScript: Ajax and Fetch

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Provide error fallbacks

Provide error fallbacks - JavaScript Tutorial

From the course: JavaScript: Ajax and Fetch

Start my 1-month free trial

Provide error fallbacks

- [Instructor] You can make your Ajax error handling code more useful by accounting for specific cases that are significant to your app and ensuring that your code can deal appropriately with each of them. Many types of Ajax errors can result in the requested data not being available to incorporate into the DOM. In this case, it's important to consider how you can meet the needs of your end users without remote data. For the Explore California form, the zip code data is just an extra, if the zip input box doesn't get autocompleted, users can still use the form and just fill it out manually, so there's no extra fallback required there. Now, the National Park section is already hidden by default and if the data isn't returned for whatever reason, that section of the page remains hidden, so we don't exactly have an issue. However, we could improve the user experience by including some default data that's displayed if we don't get a response. For instance, we could include the data for…

Contents