Changed error message to problem connecting
Consolidated xhr code