Throw exception if xmlhttprequest is not defined or has error