W3C home > Mailing lists > Public > public-webapi@w3.org > March 2007

[XMLHttpRequest] readyState values should be available as named constants of the XMLHttpRequest constructor

From: Geoffrey Garen <ggaren@apple.com>
Date: Tue, 6 Mar 2007 14:23:20 -0800
Message-Id: <5C3D54FB-71D3-44F4-84FA-12CA45BEE539@apple.com>
To: public-webapi@w3.org

Hi folks.

I would like to suggest making the canonical readyState values  
available as named constants of the XMLHttpRequest constructor, like so

      0 UninitializedReadyState
      1 OpenReadyState
      2 SentReadyState
      3 ReceivingReadyState
      4 LoadedReadyState

This code

      if (request.readyState == XMLHttpRequest.OpenReadyState) { ... }

is more readable to me that this code

      if (request.readyState == 1) { ... }

which uses a magic number. The DOM 3 APIs tend to use named constants  
like this.

Thanks,
Geoff Garen
Received on Wednesday, 7 March 2007 05:02:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:57 GMT