zoukankan      html  css  js  c++  java
  • layui框架如何在停止服务用户操作任何步骤自动跳转登录页

    今天做项目遇到了用layui框架做的一个系统,有时候当服务停止之后,后台session已经被清除,用户点击任何操作应该返回登录页面,下面是主要代码

    function backToLogin() {
    layui.use(['table', 'form'], function() {
    form = layui.form,$=layui.$;
    //超时跳转
    $.ajaxSetup({
    complete:function(XMLHttpRequest,textStatus){
    if(textStatus=="parsererror"){
                //这里不能用window.location,href,因为用了之后你会发现他是在子窗口跳转到登录页,而不是整个系统跳转
    top.location.href = '/physical/login/login';
    } else if(textStatus=="error"){
    $.messager.alert('提示信息', "请求超时!请稍后再试!", 'info');
    }
    }
    })
    });
    }
    将这个方法用在每个html页里这个地方,就是layui已经配置好之后即可对其进行跳转操作

  • 相关阅读:
    css gridlayout
    css position 属性
    简单的登陆界面
    introduce
    Event flow
    constructor和object的区别
    10th week (1)
    编程语言的历史和发展
    正则表达式的验证匹配
    js正则替换
  • 原文地址:https://www.cnblogs.com/shenwh/p/13692270.html
Copyright © 2011-2022 走看看