W3C home > Mailing lists > Public > public-webapi@w3.org > February 2008

Exceptions thrown by XMLHttpRequest.responseXML and XMLHttpRequest.responseText

From: Geoffrey Garen <ggaren@apple.com>
Date: Fri, 15 Feb 2008 09:27:03 -0800
Cc: public-webapi@w3.org
Message-Id: <3AF2220B-A3A1-4EBD-9971-D437DF509561@apple.com>
To: Anne van Kesteren <annevk@opera.com>

[ Sorry for the cross-post -- I originally sent this to the wrong  
list. ]

Hi.

The current working draft of the XMLHttpRequest spec says the  
following about responseXML and responseText.

responseText:
If the state is not LOADING or DONE raise an INVALID_STATE_ERR  
exception and terminate these steps.

responseXML:
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  
greenfieldonline.com.

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?

Thanks,
Geoff
Received on Friday, 15 February 2008 17:27:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 15 February 2008 17:27:18 GMT