The .onerror will only be invoked if there is a network error, otherwise it will always enter the .onload and ignore the onerror.
Example:
Suppose I’m on the website http://meusite.com and I have a file index.html in the root directory.
If I try to call xhr.open("GET","index.html",true);:
- Will enter the onloaderror-free, withxhr.status == 200, because
found the file normally.
If I try to call xhr.open("GET","indexxxxx.html",true);:
- Will enter the onload"mistakenly" (actually is not an error, but only a return from which the file was not found), withxhr.status == 404, because
couldn’t find the file.
If I try to call xhr.open("GET","http://google.com",true);:
- Will enter the onerror, because it is not allowed to call domain
different from the current one and the request was not even sent.
The readyState are phases of communication with the server (from 0 to 4), while the status is interpreted by browser (200, 404 etc...)
							
							
						 
that’s exactly what I wanted to know, perfect.
– user83428