#106 ✓resolved
nickg

Incorrect state values for XMLHttpRequest

Reported by nickg | March 15th, 2010 @ 07:20 AM | in 1.2.x

Fixed in commit http://github.com/thatcher/env-js/commit/2cc8e59da146072ba79c5a07cc...
Please close

regarding XMLHttpRequest.js

// it would be nice if these were part of the standard but                                                                                       
// they are not.                                                                                                                                 
XMLHttpRequest.UNSENT = 0;
XMLHttpRequest.OPEN = 0;
XMLHttpRequest.HEADERS_RECEIVED = 0;
XMLHttpRequest.LOADING = 0;
XMLHttpRequest.DONE = 4;

True they not in the spec as pure javascript values. Safari/Chrome does expose them as

XMLHttpRequest.UNSENT = 0;
XMLHttpRequest.OPEN = 1;
XMLHttpRequest.HEADERS_RECEIVED = 2;
XMLHttpRequest.LOADING = 3;
XMLHttpRequest.DONE = 4;

. Firefox does not, IE don't know. Certainly have envjs.org defining the first four to be "0" seems odd. (And using them in the code would make it more readable).

The following micro script might be useful for testing

<html><head><title>XMLHttpRequest</title></head><body>
<pre><script type="text/javascript">
var x= new XMLHttpRequest();
for (var i in x) {
 document.write(i + ": " + x[i] + "\n");
}
</script></pre></body></html>


The spec http://www.w3.org/TR/XMLHttpRequest/ says:

// states const unsigned short UNSENT = 0; const unsigned short OPENED = 1; const unsigned short HEADERS_RECEIVED = 2; const unsigned short LOADING = 3; const unsigned short DONE = 4; readonly attribute unsigned short readyState;


Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

a javascript browser environment

People watching this ticket

Referenced by

Pages