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"); }原文链接:https://www.f2er.com/ajax/161977.html