use onload/onerror events on xhr2
Automatically rewritten for npm.