added ajax replay method and fixed retry logic

The retry logic wasnt really working earlier. Changed it around a little bit so we always retry only once whenever there's either refreshtoken or authHandler provided.