synchronise ajax calls when logging in