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"); }