When an Ajax call returns, there's no additional step that you need to wait for. That's the main concept of a callback — no arbitrary/unpredictable polling delays are necessary.
With the checkPermissions, it's not that you may not need to call it multiple times, but you never need to wait to check the hash if you just set it.
document.location.hash = "#something";
// the hash is guaranteed to be "#something" here, there is no race condition
Plus, I see there's yet another timeout around the new reCAPTCHA code. This too isn't going to work... you can't just guess about when an async script has been loaded! The first time I loaded the page in fact I got this error:
That was because you tried to use the grecaptcha object before it existed, and that wasn't within the arbitrary timeout interval. You need to wait for the load event on the script.
Plus the onloadCallback function isn't defined.
Just too many moving parts here, the code needs to be refactored to have a guaranteed chain of events.
... View more