[whatwg] Exceptions thrown by XMLHttpRequest.responseXML and XMLHttpRequest.responseText
ggaren at apple.com
Fri Feb 15 09:19:14 PST 2008
The current working draft of the XMLHttpRequest spec says the
following about responseXML and responseText.
If the state is not LOADING or DONE raise an INVALID_STATE_ERR
exception and terminate these steps.
If the state is not DONE raise an INVALID_STATE_ERR exception and
terminate these steps.
While implementing this specification in WebKit, we gathered the
following pieces of data:
1. This specification breaks at least one AJAX library, used by
2. This specification does not match any shipping version of Safari or
Firefox, which do not throw exceptions.
3. This specification does not match any shipping version of Internet
Explorer, which throws exceptions in some of these conditions, but not
all. (The specifics here are a little weird, so I'll leave them out.)
4. Generally speaking, throwing an exception, which aborts a program,
is a much bigger compatibility risk than not throwing an exception.
Therefore, for WebKit, I've decided that the most compatible and least
weird behavior is not to throw an exception when accessing
responseText or responseXML. Rather, for responseText, return the
empty string, and for responseXML, return null.
Would you be willing to consider editing the XMLHttpRequest spec to
match this behavior?
More information about the whatwg