后台无法判断ajax请求的解决办法
发布时间:2020-12-16 01:31:44 所属栏目:百科 来源:网络整理
导读:var xhr = new XMLHttpRequest();xhr.open("get",remoteUrl);xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.onload = function(){};xhr.send(); public static boolean isAjax(HttpServletRequest request) { return request.getHeader("x
var xhr = new XMLHttpRequest(); xhr.open("get",remoteUrl); xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"); xhr.onload = function(){}; xhr.send(); public static boolean isAjax(HttpServletRequest request) { return request.getHeader("x-requested-with") != null && request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest"); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |