The XMLHttpRequest.readyState property returns the state an XMLHttpRequest client is in.
MDN Reference