title: Redirect on Ajax Jquery Call
body: <p>I am newbie to ajax here and I know somebody would have encountered this problem already.
  I have a legacy app built on Spring MVC, it has a interceptor(filter) that redirects the user to the login
  page whenever there is no session.</p>
  
  <pre><code>public class SessionCheckerInterceptor extends HandlerInterceptorAdapter {
   public boolean preHandle(HttpServletRequest request,
     HttpServletResponse response, Object handler) throws Exception {
    HttpSession session = request.getSession();
  
    // check if userInfo exist in session
    User user = (User) session.getAttribute("user");
    if (user == null) {
     response.sendRedirect("login.htm");
     return false;
    }
    return true;
   }
  }
  </code></pre>
  
  <p>For non-xmlhttp request, this works fine.. but when I try to use ajax in my application, everything gets weird,
  it is not able to redirect to the login page correctly.
  As check the value of the</p>
  
  <p>xhr.status = 200  textStatus = parseError  errorThrown = "Invalid JSON -Markup of my HTML Login Page-</p>
  
  <pre><code>$(document).ready(function(){
          jQuery.ajax({
              type: "GET",
              url: "populateData.htm",
              dataType:"json",
              data:"userId=SampleUser",
              success:function(response){
               //code here
              },
           error: function(xhr, textStatus, errorThrown) {
                  alert('Error!  Status = ' + xhr.status);
               }
  
          });
  });
  </code></pre>
  
  <p>I checked on my firebug that there is a 302 HTTP response but I am not sure how to catch the response and redirect the user to the login
  page.  Any idea here?  Thanks.</p>