better ajax connection handeling with errors