Fix xhr onreadystatechange firing multiple times with state 4.
Merge pull request #566 from nlacasse/xhr-bug

Fix xhr onreadystatechange firing multiple times with state 4.