From the course: JavaScript: Ajax and Fetch
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Provide error fallbacks - JavaScript Tutorial
From the course: JavaScript: Ajax and Fetch
Provide error fallbacks
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. One of those 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 isn't auto completed, users can still use the form and fill in that manually, so there's no extra fallback required here. The national park section is already hidden by default, and if the data isn't returned for whatever reason, it remains hidden so we don't 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 one of the parks in the code for the page and set up our…
Contents
-
-
-
-
-
-
-
(Locked)
Structure AJAX requests for performance2m 38s
-
(Locked)
View requests and responses in the browser3m 52s
-
(Locked)
Work with authorization errors3m 28s
-
(Locked)
Work with malformed requests5m 8s
-
(Locked)
Work with errors in Fetch4m 44s
-
(Locked)
Provide error fallbacks6m 23s
-
(Locked)
Challenge: Fix an AJAX request38s
-
(Locked)
Solution: Fix an AJAX request4m 31s
-
(Locked)
-