Fixed ajax call to endpoint when the Walled Garden is enabled.

Problem with ajax querys, when the Walled Garde is enabled.
How to replicate it:
If you are in tab (1) logged in, and into another tab (2) you log out.
Then an ajax call was made into the tab (1).
Then when you try to log in again into tab (2), will be redirected to the 
endpoint file. :S