
Explanation:
The key requirements are that API calls should not delay UI rendering and it's acceptable to omit the API data on errors.
asynchronous: false), which block the UI thread, delaying rendering. This violates the requirement to avoid delaying other parts of the UI.asynchronous: true), allowing non-blocking UI rendering. Omitting the widget on errors aligns with the requirement to tolerate missing API data.Thus, B is the correct choice as it satisfies both non-blocking UI and graceful handling of API failures.
Ultimate access to all questions.
No comments yet.
How should you design a single-page web application where the UI communicates with a third-party API via XMLHttpRequest, ensuring that non-critical API data doesn't block UI rendering, while maintaining good performance during API errors or timeouts?
A
Set the asynchronous option for your requests to the API to false and omit the widget displaying the API results when a timeout or error is encountered.
B
Set the asynchronous option for your request to the API to true and omit the widget displaying the API results when a timeout or error is encountered.
C
Catch timeout or error exceptions from the API call and keep trying with exponential backoff until the API response is successful.
D
Catch timeout or error exceptions from the API call and display the error response in the UI widget.