Added retrying to ajax functions when fail