I need to support major modern browsers only (IE10+, FF, Chrome, Safari)
Can I make this substitution as I want to simplify my code base:
From:
In the MDN documentation they state the following
Events
onreadystatechange as a property on the xhr object is supported in all browsers.
Since then, a number of additional event handlers were implemented in various browsers (onload, onerror, onprogress, etc.). These are supported in Firefox. In particular, see nsIXMLHttpRequestEventTarget and Using XMLHttpRequest.
More recent browsers, including Firefox, also support listening to the XMLHttpRequest events via standard addEventListener APIs in addition to setting on* properties to a handler function.
So I think you can assume that onreadystatechange is the way to go and onload is a addition that can be used if the browser supports it. @mr.VVoo answer is the correct one, to stick to w3c when in doubt.