This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22058 - "error" event should fire before final readystatechange event
Summary: "error" event should fire before final readystatechange event
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: XHR (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-16 09:42 UTC by Hallvord R. M. Steen
Modified: 2013-05-16 11:40 UTC (History)
2 users (show)

See Also:


Attachments

Description Hallvord R. M. Steen 2013-05-16 09:42:00 UTC
#request-error part of spec:

Step 6: Fire an event named readystatechange. 

.
.

Step 9: Fire a progress event named event. // this fires the actual 'error' event

This seems to be an order of events that isn't really user-friendly. 

Given a typical XHR-using script has logic like this:

if readystatechange fires with readyState === 4
  report "success", handle response data

if error event fires
  report failure

this typical XHR user would end up running the "success" code first, then the "failure" code. This seems less than ideal.. Is there any reason we can't move the "fire error" step to before the "fire readystatechange" step?
Comment 1 Hallvord R. M. Steen 2013-05-16 09:51:02 UTC
(I guess the real answer is "we want to push users to not rely on readystatechange but use load/error events instead" :-p)
Comment 2 Anne 2013-05-16 11:40:28 UTC
Either fully use readystatechange or use the other set of events. If you start mixing, you're on your own.