- 
				
				
qq_花开花谢_0
				123456789101112131415$.ajax({      url:"xxxxxx",    type:"post",      dataType:"json",      data:"hello world",      headers: {'Content-Type': 'application/json'},      success: function (ret) {            if (ret.status == 1) {                  window.location.reload();            } else {                  alert(ret.message);            }      }})    使用post请求,这里的data里的参数就是在body形式传过去。
				
			 
			
			- 
				
				
有只小跳蛙
				12345678public boolean isAjaxRequest(HttpServletRequest request){      String header = request.getHeader("X-Requested-With");    if ("XMLHttpRequest".equals(header)) {        return true;    } else {        return false;    }}
				
			 
			
			- 
				
				
心有法竹
				普通情况下没法判断不过如果使用jquery做ajax 会自动在请求的header里面加上一个 x-request-with 可以通过这个判断。望采纳! <html><!DOCTYPE html> <html> <head> <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","/try/ajax/demo_get.php",true); xmlhttp.send(); } </script> </head> <body> <h2>AJAX</h2> <button type="button" onclick="loadXMLDoc()">Request data</button> <div id="myDiv"></div> </body> </html>