Fix xhr event handling.

Onload is called whenever we successfully completed the communication
with the server (including error cases like 404). Onerror is for lower
level errors (and thus status and statusText aren't available there).