加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

请求超时弹出提示

发布时间:2020-12-16 01:29:36 所属栏目:百科 来源:网络整理
导读:1、判断普通请求还是ajax请求分别跳转 if(isAjaxRequest){//是ajax请求PrintWriter wirter = response.getWriter(); wirter.write("timeout"); wirter.flush();} else {//非ajax请求直接跳转response.sendRedirect(loginUrl + "?service=" + service);} 2、a

1、判断普通请求还是ajax请求分别跳转

if(isAjaxRequest){//是ajax请求
					PrintWriter wirter =  response.getWriter();
				    wirter.write("timeout");
				    wirter.flush();
				} else {//非ajax请求直接跳转
					response.sendRedirect(loginUrl + "?service=" + service);
				}

2、ajax请求超时处理

$.ajaxSetup({
	global: false,type: "POST",complete: function (XMLHttpRequest,textStatus) {
		var data = XMLHttpRequest.responseText;
		if (data == "timeout") {
			//if( window.top != window.self ){
				// window.top.location = "${pageContext.request.contextPath}";
				alert('请重新登录!');
			//}
		}
	}
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读