Fix spring-security Session Timeout Ajax request no redirect issue

Source: Internet
Author: User



At the beginning, the code is like this:


$.ajax({
             Type : "POST",
             Url : sSource,
             Cache : false,
             dataType : "json",
             Data : aoData,
             Success : function(resp) {
                 Alert(11)
                 fnCallback(resp);
                 $.dialog.tips(‘Data loaded ‘, 1, ‘success.gif‘, function() { });
             }
         }); 


Spring-security session timeout, the query button can still click, and did not jump, observed that this method has problems.






Knowing more about the use of Ajax requests, the problem is that the request is in JSON format, and after the spring-security session expires, the redirected login page is returned, so we know what to do.



The reason is not complex, the solution is simple,---added error handling methods, problem solving!


,
             Error: function (XMLHttpRequest, textStatus, errorThrown) {
                 /* alert(textStatus)// here is parseFailue
                 Alert(errorThrown) // This shows that the parsing json error is
                 Alert(XMLHttpRequest) */
                 responseText = XMLHttpRequest.responseText
                 // alert ( responseText )
                   Document.write(responseText); //
             },
             Complete: function (XMLHttpRequest, textStatus) {
                
             } 


Keep it down!






Fix spring-security Session Timeout Ajax request no redirect issue


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.