We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

An EventHandler that is called whenever the readyState attribute changes. The callback is called from the user interface thread. The XMLHttpRequest.onreadystatechange property contains the event handler to be called when the readystatechange event is fired, that is every time the readyState property of the XMLHttpRequest changes.

Warning: This should not be used with synchronous requests and must not be used from native code.


XMLHttpRequest.onreadystatechange = callback;


  • callback is the function to be executed when the readyState changes.


var xhr = new XMLHttpRequest(),
    method = "GET",
    url = "https://developer.mozilla.org/";

xhr.open(method, url, true);
xhr.onreadystatechange = function () {
  if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {


Specification Status Comment
XMLHttpRequest Living Standard WHATWG living standard

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support1 Yes171 Yes1.2
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes1 Yes Yes Yes ? ?

1. Internet Explorer version 5 and 6 supported ajax calls using ActiveXObject()

Document Tags and Contributors

 Last updated by: ExE_Boss,