Detect an AJAX request
public static boolean isAjax(request) { return "XMLHttpRequest".equals(request.getHeader("X-Requested-With")); }