XMLHttpRequest
XMLHttpRequest is an event-based browser request API. load means the transfer completed, not necessarily that its HTTP status indicates success.
Separate setup, completion, status checks and network errors when maintaining older request code.
See the mechanism
open(method, url)handlers registeredFollow one example
open configures the request; send starts it. onload checks status before parsing the returned text. onerror handles network failure, while parsing can fail separately. This preview uses a local data fixture and does not emulate every HTTP outcome. Prefer the API appropriate to the project; XHR remains relevant for legacy code and some progress-reporting use cases, not as a required replacement for fetch.
Predict, change and check
Predict: If open is called but send is removed, has the request actually started?
Test your explanation: Remove send and observe the pending interface, then restore it. In a real endpoint example, add timeout and abort handling rather than treating every completion as success.
The tasks below ask you to explain that result and apply the idea to different inputs.
Apply and distinguish
Legacy transport still needs a complete lifecycle
XMLHttpRequest exposes an event-driven request interface. A load event means the transfer completed, not that the status represents application success. Inspect the status and choose the expected response representation. Network error, abort and timeout need distinct handlers or a deliberate shared recovery policy.
Do not present a fulfilled XHR example as a reason to ignore cancellation or payload validation. Prefer the API that fits the product and environment while understanding legacy code you may need to maintain. In a data-URL example, focus on the API lifecycle; test real HTTP status and access behavior against a server contract separately.
Check your understanding: State the input contract, identify the operation that changes the result, and give one boundary input that would distinguish the correct rule from the mistake described above.