Tried to tackle CORS error-handling. Added an xhr.onerror() function.