Вопрос

I'm implementing logout functionality for a web application. I have a function, which is called when the user clicks the sign out button.

$.post(window.location.pathname + '/logout');

The logout service works only with post.

What happens is:

  1. The 302 status is returned as expected with Location: http://myapp.com/logout.html
  2. Apparently the jquery ajax call just picks up from there and immediately makes a GET request to said location.
  3. The GET request returns the correct html, but it returns it AJAX style, the redirect page is not loaded by the browser

What I would like to happen is:

  1. The 302 status is returned as expected with Location: http://myapp.com/logout.html
  2. The browser redirects to the given location
Это было полезно?

Решение

If you don't want to handle the response using Ajax, then don't use Ajax.

<form action="/logout" method="post">
    <input type="submit" value="logout">
</form>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top