I am using google open id on my website as a login system. I ran into some trouble with logging a user out. Destroying the session on the site obviously doesn't log them out of the google account, and on the next login the user automatically logs in with whatever google account the browser is logged into.
Looking at a few questions on here, I discovered I could just make a request to https://www.google.com/accounts/Logout
I tried using
<script type="text/javascript">
$.ajax({ url: "https://www.google.com/accounts/Logout" });
</script>
but it did not work and I'm not sure why. However this works just fine
<img src="https://www.google.com/accounts/Logout" />
Can anyone explain to me why the ajax request doesn't work?
Edit:
More importantly, what is the best way to send the request? An img tag doesn't seem like a nice solution. Thanks
You cannot make cross-domain requests using jQuery's
$.ajax
, see Same origin policy so that is why your first solution does not work.Edit: I am not familiar with how Google's OpenID works, but as a user I would not use an app that logs me out of Google when I want to logout of the app; that's a bad user experience.