Why in requests 1 lesson it is using onreadystatechange instead of onload?

I wanted to know why in the requests-i,JavaScript lesson it is like

  xhr.onreadystatechange = () => {
    if (xhr.readyState === XMLHttpRequest.DONE) {
      renderByteResponse(xhr.response);
    }

Instead of just simply writing:

xhr.onload = () => {
  renderByteResponse(xhr.response);
}

Can anyone clarify it?
Thanks in advance!