Ajax Session Timeout

Source: Internet
Author: User

1. problem: the client sends an Ajax request, but the session times out.

2. solution:

Server: in the filter or interceptor, determine the Ajax request type and set a timeout flag.

Client: the Ajax request requires a global processing function to obtain the corresponding flag and process it accordingly.

 

  1. Add the following to the filter:
  2. // If there is an Ajax Request Response Header, X-requested-with; If (req. getheader ("X-requested-")! = NULL & Req. getheader ("X-requested-with"). inclusignorecase ("XMLHttpRequest") {res. setstatus (911); // indicates Session Timeout return ;}

Foreground global processing Ajax:

$. Ajaxsetup ({Timeout: 4000, cache: false, complete: function (xhr, textstatus) {// Session Timeout if (xhr. status = 911) {window. location. href = ".. /login. JSP "// return to the application homepage return ;}}});

Ajax Session Timeout

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.