I have a Facebook login button that users log in with. After they log in, I collect their credentials, and log them into the session. Then after the AJAX call, I refresh the page like this with JavaScript:
location.reload(true);
This seems to be confusing the request variable and the AJAX doesn’t get called. Is there a way to wait for the ajax call to complete before I refresh?
What do people usually do in this sort of a situation?
Thanks!
ps – I am testing this on this test page if anyone wants to try: http://www.comehike.com/test_fb_connect.php
Why not put the refresh in the callback?
the
onreadystatechangecallback function gets called after the ajax request is finished. So that’s when you want to refresh the page because you know all the ajax stuff is done. If you putlocation.reload(true)after the callback, it will get run before the callback.request.send(null)runs before theonreadystatechangecallback does.