title: Successful ajax post to spring security doesn't redirect
body: <p>Folks, I have a problem where a successful ajax POST (200) request to j_spring_security_check doesn't redirect correctly to a success.jsp page - which is in the same directory as the login page. The login.jsp page just redisplays - and I can't figure out why (Please note, I'm fairly new to ajax).</p>
  
  <p>Following is the content of my login.jsp page. Any help would be greatly received:</p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"&gt;&lt;/script&gt;
      &lt;%--&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"&gt;&lt;/script&gt;--%&gt;
      &lt;title&gt;Money Tracker - Logon&lt;/title&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
        &lt;div&gt;
          &lt;header&gt;
          &lt;/header&gt;
          &lt;section&gt;
            &lt;div id="dialog" title="Login"&gt;
              &lt;form id="login"&gt;
                  &lt;label for="userName"&gt;User:&lt;/label&gt;
                  &lt;input id="userName" type="text" name="userName"&gt;
                  &lt;br&gt;
                  &lt;label for="password"&gt;Password:&lt;/label&gt;
                  &lt;input id="password" type="password" name="password"&gt;
                  &lt;br&gt;
                  &lt;label for="rememberMe"&gt;Remember me&lt;/label&gt;
                  &lt;input id="rememberMe" type="checkbox" name="rememberMe"/&gt;
                  &lt;br&gt;
                 &lt;button type="submit"&gt;Login&lt;/button&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/section&gt;
  &lt;/div&gt;
  &lt;script&gt;
  
  function ajaxLogin(form) {
      var userName = form.userName.value;
      var password = form.password.value;
      var rememberMe = form.rememberMe.value;
      $.ajax({
          cache: false,
          type: 'POST',
          url: "/server/j_spring_security_check",
          crossDomain: true,
          async: false,
          data: { j_username: userName, j_password: password, _spring_security_remember_me: rememberMe },
          beforeSend: function (xhr) {
              xhr.setRequestHeader("x-ajax-call", "true");
          },
          success: function (result, xhr) {
              alert("Request was success. Status is: " + xhr.status);
              if (result == "ok") {
                  alert("Result was OK. Status is: " + xhr.status);
                  window.location.href = "success.jsp";
              } else {
                  alert("Result was not OK. Status is: " + xhr.status);
                  location.href = "loginFailed.jsp";
              }
  
          },
          error: function (xhr) {
              alert("Error with request. Status is: " + xhr.status);
              location.href = "loginFailed.jsp"
          },
          complete: function(result) {
          }
      });
  }
  
  $(function () {
      $("#login").submit(function () {
          ajaxLogin(this)
      });
  });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>